This method will take in any two graphs and output the direct product of these two graphs. The vertex set of the direct product of G and H is the cartesian product of G and H's vertex sets. The keys for each vertex will be output as a sequence to represent this. Any two vertices (u,u') and (v,v') form an edge in the direct product of G and G if and only if u' is adjacent with v' and u is adjacent with v in the original graphs.
i1 : G = graph({1,2},{{1,2}}); |
i2 : H = graph({3,4,5},{{3,4},{4,5}}); |
i3 : G'= directProduct(G,H) o3 = Graph{(1, 3) => {(2, 4)} } (1, 4) => {(2, 5), (2, 3)} (1, 5) => {(2, 4)} (2, 3) => {(1, 4)} (2, 4) => {(1, 3), (1, 5)} (2, 5) => {(1, 4)} o3 : Graph |
The object directProduct is a method function.