Esempio n. 1
0
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
Esempio n. 2
0
def gridGraph(m, n):
    return graphCartesianProduct(path(m), path(n))