Plotting hypercube graphs

Plotting hypercube graphs#

n=6
g = graphs.CubeGraph(n, embedding=2)
g.show(figsize=[12,12],vertex_labels=True, vertex_size=0,vertex_color='white',edge_thickness=0.5)
_images/8ca2c7c7b060883791030f2803ae002ed74d2418e625a116026f67dacb890ba6.png
(BFSVertexList,BFSTree) = g.lex_BFS(tree=True,initial_vertex="0" * n)
BFSTree = BFSTree.to_undirected()
BFSTree.show(figsize=[12,12], vertex_labels=True, 
             vertex_size=0, vertex_color='white', edge_thickness=0.4, pos=g.get_pos())
print(BFSVertexList)
d = dict((BFSVertexList[i],i) for i in range(len(BFSVertexList)))
print(d)
_images/aa793a621cc1c4f3f19c02562268fd3107f0bb155ba93a79831d1f676a8ce5a3.png
['000000', '010000', '100000', '000001', '000010', '000100', '001000', '110000', '010001', '010010', '010100', '011000', '100001', '100010', '100100', '101000', '000011', '000101', '001001', '000110', '001010', '001100', '110001', '110010', '110100', '111000', '010011', '010101', '011001', '010110', '011010', '011100', '100011', '100101', '101001', '100110', '101010', '101100', '000111', '001011', '001101', '001110', '110011', '110101', '111001', '110110', '111010', '111100', '010111', '011011', '011101', '011110', '100111', '101011', '101101', '101110', '001111', '110111', '111011', '111101', '111110', '011111', '101111', '111111']
{'000000': 0, '010000': 1, '100000': 2, '000001': 3, '000010': 4, '000100': 5, '001000': 6, '110000': 7, '010001': 8, '010010': 9, '010100': 10, '011000': 11, '100001': 12, '100010': 13, '100100': 14, '101000': 15, '000011': 16, '000101': 17, '001001': 18, '000110': 19, '001010': 20, '001100': 21, '110001': 22, '110010': 23, '110100': 24, '111000': 25, '010011': 26, '010101': 27, '011001': 28, '010110': 29, '011010': 30, '011100': 31, '100011': 32, '100101': 33, '101001': 34, '100110': 35, '101010': 36, '101100': 37, '000111': 38, '001011': 39, '001101': 40, '001110': 41, '110011': 42, '110101': 43, '111001': 44, '110110': 45, '111010': 46, '111100': 47, '010111': 48, '011011': 49, '011101': 50, '011110': 51, '100111': 52, '101011': 53, '101101': 54, '101110': 55, '001111': 56, '110111': 57, '111011': 58, '111101': 59, '111110': 60, '011111': 61, '101111': 62, '111111': 63}
binary_string = "101010"  # Replace this with your binary string
binary_list = [int(bit) for bit in binary_string]
print(binary_list)
[1, 0, 1, 0, 1, 0]