Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hypercube Graph
import networkx as nx
import matplotlib.pyplot as plt
from math import log
def hypercube_graph(n):
"""Create a hypercube graph of size n
(int) -> Graph
"""
H = nx.Graph()
for i in range(2**n):
for j in range(n):
print(i, 2**j, i^2**j)
H.add_edge(i,i^2**j)
return H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.