GraphProduct[g1,g2]
gives the Cartesian product of the graphs g1 and g2.
GraphProduct[g1,g2,"op"]
gives the product of type "op" for the graphs g1 and g2
GraphProduct
GraphProduct[g1,g2]
gives the Cartesian product of the graphs g1 and g2.
GraphProduct[g1,g2,"op"]
gives the product of type "op" for the graphs g1 and g2
Details and Options
- GraphProduct is also known as box product.
- GraphProduct is typically used to produce new graphs from Boolean combinations of initial graphs.
- GraphProduct[g1,g2] gives a graph with vertices formed from the Cartesian product of the vertices of g1 and vertices of g2. The vertices {u1,u2} and {v1,v2} are connected if u1v1 and u2 is connected to v2, or u2v2 and u1 is connected to v1.
- GraphProduct[g1,g2,"op"] gives a graph product of type "op" with edges {u1,u2}{v1,v2} subject to the following conditions:
-
"Cartesian" (u1v1 ∧ u2v2)∨(u2v2∧u1v1) "Conormal" (u1v1)∨(u2v2) "Lexicographical" (u1v1)∨(u1v1∧u2v2) "Normal" (u1v1∧u2v2)∨(u2v2∧u1v1)∨(u1v1∧u2v2) "Rooted" (u1v1 ∧ u2v2)∨(u1v1 ∧ u2v2r) "Tensor" (u1v1)∧(u2v2) - The vertex r is the first vertex in VertexList[g2].
- GraphProduct[g1,g2] is effectively equivalent to GraphProduct[g1,g2,"Cartesian"].
- GraphProduct works with undirected graphs, directed graphs, multigraphs and mixed graphs.
Examples
open all close allBasic Examples (3)
Cartesian product of two graphs:
GraphProduct[[image], [image]]Table[GraphProduct[[image], [image], op, Rule[...]], {op, {...}}]GraphProduct[PathGraph[{1, 2, 3}], PathGraph[{1, 2, 3, 4}], GraphLayout -> "GridEmbedding"]GraphProduct[CycleGraph[10], CycleGraph[6], GraphLayout -> "SpringElectricalEmbedding"]Scope (30)
Directed Graphs (5)
GraphProduct works with directed graphs:
GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]Undirected Graphs (5)
GraphProduct works with undirected graphs:
GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]Mixed Graphs (5)
GraphProduct works with mixed graphs:
GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]Multigraphs (5)
GraphProduct works with multigraphs:
GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]Weighted Graphs (5)
GraphProduct works with weighted graphs:
GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]GraphProduct[[image], [image]]Special Graphs (5)
GraphProduct works on entity graphs:
GraphProduct[["petersen graph"], ["petersen graph"]]GraphProduct works on trees:
GraphProduct[[image], [image]]Use rules to specify the graph:
GraphProduct[{1 -> 2, 2 -> 3, 3 -> 4, 4 -> 1}, {1 -> 2}]GraphProduct works with more than two graphs:
GraphProduct[[image], [image], [image]]Generate a list of different graph products:
{g, h} = {[image], [image]};Table[GraphProduct[g, h, type], {type, {"Cartesian", "Tensor", "Lexicographical", "Normal", "Conormal", "Rooted"}}]Properties & Relations (6)
For two graphs with vi vertices, the number of vertices of their product is v1 v2 :
g = [image]; h = [image];VertexCount[GraphProduct[g, h]] == VertexCount[g] * VertexCount[h]For two undirected graphs with vi vertices and ei edges, the number of edges of the Cartesian product is v1 e2+v2 e1:
g = [image]; h = [image];{v1, v2} = VertexCount /@ {g, h};{e1, e2} = EdgeCount /@ {g, h};EdgeCount@GraphProduct[g, h, "Cartesian"] == v1 * e2 + v2 * e1EdgeCount@GraphProduct[g, h, "Tensor"] == 2e1 e2Lexicographical product is v1 e2+ e1v22 :
EdgeCount@GraphProduct[g, h, "Lexicographical"] == v1 * e2 + e1 * v2 ^ 2Normal product is v1 e2+v2 e1 + 2 e1e2:
EdgeCount@GraphProduct[g, h, "Normal"] == v1 * e2 + v2 * e1 + 2e1 e2Co-normal product is v12 e2+ e1v22 - 2e1e2:
EdgeCount@GraphProduct[g, h, "Conormal"] == v1 ^ 2 * e2 + e1 * v2 ^ 2 - 2e1 e2EdgeCount@GraphProduct[g, h, "Rooted"] == v1 * e2 + e1The Cartesian product of two single edges is a cycle:
GraphProduct[[image], [image], "Cartesian"]The normal product of two single edges is a complete graph:
GraphProduct[[image], [image], "Normal"]The tensor product of two single edges is a cross:
GraphProduct[[image], [image], "Tensor"]TorusGraph[{m,n}] is the graph formed from the Cartesian product of the cycle graphs
and
:
g = TorusGraph[{10, 6}]h = GraphProduct[CycleGraph[10], CycleGraph[6]]IsomorphicGraphQ[g, h]Related Guides
History
Text
Wolfram Research (2022), GraphProduct, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphProduct.html.
CMS
Wolfram Language. 2022. "GraphProduct." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GraphProduct.html.
APA
Wolfram Language. (2022). GraphProduct. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphProduct.html
BibTeX
@misc{reference.wolfram_2026_graphproduct, author="Wolfram Research", title="{GraphProduct}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/GraphProduct.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphproduct, organization={Wolfram Research}, title={GraphProduct}, year={2022}, url={https://reference.wolfram.com/language/ref/GraphProduct.html}, note=[Accessed: 13-June-2026]}