def hypercube(k): ''' Returns the $k$-dimensional hypercube graph. See West, p. 36, example 1.3.8. ''' G = completeGraph(1) P2 = completeGraph(2) while k: G = graphCartesianProduct(G, P2) k -= 1 return G
def gridGraph(m, n): return graphCartesianProduct(path(m), path(n))