next | previous | forward | backward | up | index | toc

# cartesianProduct -- Computes the cartesian product of two graphs

## Synopsis

• Usage:
F = cartesianProduct(G,H)
• Inputs:
• G, ,
• H, ,
• Outputs:
• F, , The Cartesian Product of G and H

## Description

This method will take in any two graphs and output the cartesian product of the two graphs. The vertex set of this new graph is the cartesian product of the vertex sets of the two input graphs. The keys for each vertex will be output as a sequence. Any two vertices (u,u') and (v,v') are adjacent in the cartesian product of G and H if and only if either u = v and u' is adjacent with v' in H, or u' = v' and u is adjacent with v in G.

 i1 : G = graph({1,2},{{1,2}}); i2 : H = graph({3,4,5},{{3,4},{4,5}}); i3 : G' = cartesianProduct(G,H) o3 = Graph{(1, 3) => {(2, 3), (1, 4)} } (1, 4) => {(1, 3), (2, 4), (1, 5)} (1, 5) => {(2, 5), (1, 4)} (2, 3) => {(1, 3), (2, 4)} (2, 4) => {(2, 5), (2, 3), (1, 4)} (2, 5) => {(2, 4), (1, 5)} o3 : Graph