Skip to content

Instantly share code, notes, and snippets.

@karthikraman
Created May 20, 2016 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karthikraman/dc405ce1a7982dd0b8906307aceaee25 to your computer and use it in GitHub Desktop.
Save karthikraman/dc405ce1a7982dd0b8906307aceaee25 to your computer and use it in GitHub Desktop.
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