# Cartesian product of graphs

In graph theory, the Cartesian product G □ H of graphs G and H is a graph such that:
* the vertex set of G □ H is the Cartesian product V(G) × V(H); and
* two vertices (u,v) and (u' ,v' ) are adjacent in G □ H if and only if either
** u = u' and v is adjacent to v' in H, or
** v = v' and u is adjacent to u' in G.
The Cartesian product of graphs is sometimes called the box product of graphs [Harary 1969].
The operation is associative, as the graphs (F □ G) □ H and F □ (G □ H) are naturally isomorphic. The operation is commutative as an operation on isomorphism classes of graphs, and more strongly the graphs G □ H and H □ G are naturally isomorphic, but it is not commutative as an operation on labeled graphs.
The notation G × H has often been used for Cartesian products of graphs, but is now more commonly used for another construction known as the tensor product of graphs. The square symbol is intended to be an intuitive and unambiguous notation for the Cartesian product, since it shows visually the four edges resulting from the Cartesian product of two edges.

## Examples

* The Cartesian product of two edges is a cycle on four vertices: K$_2$□K$_2$ = C$_4$.
* The Cartesian product of K$_2$ and a path graph is a ladder graph.
* The Cartesian product of two path graphs is a grid graph.
* The Cartesian product of n edges is a hypercube:
       $(K_{2})^{\square n}=Q_{n}.$
    Thus, the Cartesian product of two hypercube graphs is another hypercube: Q$_i$□Q$_j$ = Q$_{i+j}$.
* The Cartesian product of two median graphs is another median graph.
* The graph of vertices and edges of an n-prism is the Cartesian product graph K$_2$□C$_n$.
* The rook's graph is the Cartesian product of two complete graphs.

## Properties

If a connected graph is a Cartesian product, it can be factorized uniquely as a product of prime factors, graphs that cannot themselves be decomposed as products of graphs. However, Imrich & Klavžar (2000) describe a disconnected graph that can be expressed in two different ways as a Cartesian product of prime graphs:
    $(K_{1}+K_{2}+K_{2}^{2})\mathbin {\square } (K_{1}+K_{2}^{3})=(K_{1}+K_{2}^{2}+K_{2}^{4})\mathbin {\square } (K_{1}+K_{2}),$
where the plus sign denotes disjoint union and the superscripts denote exponentiation over Cartesian products. This is related to the identity that
    ${\begin{aligned}(1+x+x^{2})(1+x^{3})&=(1+x^{2}+x^{4})(1+x)\\&=1+x+x^{2}+x^{3}+x^{4}+x^{5}\\&=(1+x)(1+x+x^{2})(1-x+x^{2})\end{aligned}}$
Both the factors $1+x^{3}$ and $1+x^{2}+x^{4}$ are not irreducible polynomials, but their factors include negative coefficients and thus the corresponding graphs cannot be decomposed. In this sense, the failure of unique factorization on (possibly disconnected) graphs is akin to the statement that polynomials with nonnegative integer coefficients is a semiring that fails the unique factorization property.
A Cartesian product is vertex transitive if and only if each of its factors is.
A Cartesian product is bipartite if and only if each of its factors is. More generally, the chromatic number of the Cartesian product satisfies the equation
    $\chi (G\mathbin {\square } H)=\max\{\chi (G),\chi (H)\}.$
The Hedetniemi conjecture states a related equality for the tensor product of graphs. The independence number of a Cartesian product is not so easily calculated, but as Vizing (1963) showed it satisfies the inequalities
    $\alpha (G)\alpha (H)+\min\{|V(G)|-\alpha (G),|V(H)|-\alpha (H)\}\leq \alpha (G\mathbin {\square } H)\leq \min\{\alpha (G)|V(H)|,\alpha (H)|V(G)|\}.$
The Vizing conjecture states that the domination number of a Cartesian product satisfies the inequality
    $\gamma (G\mathbin {\square } H)\geq \gamma (G)\gamma (H).$
The Cartesian product of unit distance graphs is another unit distance graph.
Cartesian product graphs can be recognized efficiently, in linear time.

## Algebraic graph theory

Algebraic graph theory can be used to analyse the Cartesian graph product. If the graph $G_{1}$ has $n_{1}$ vertices and the $n_{1}\times n_{1}$ adjacency matrix $\mathbf {A} _{1}$, and the graph $G_{2}$ has $n_{2}$ vertices and the $n_{2}\times n_{2}$ adjacency matrix $\mathbf {A} _{2}$, then the adjacency matrix of the Cartesian product of both graphs is given by
    $\mathbf {A} _{1\mathbin {\square } 2}=\mathbf {A} _{1}\otimes \mathbf {I} _{n_{2}}+\mathbf {I} _{n_{1}}\otimes \mathbf {A} _{2}$,
where $\otimes$ denotes the Kronecker product of matrices and $\mathbf {I} _{n}$ denotes the $n\times n$ identity matrix. The adjacency matrix of the Cartesian graph product is therefore the Kronecker sum of the adjacency matrices of the factors.

## Category theory

Viewing a graph as a category whose objects are the vertices and whose morphisms are the paths in the graph, the cartesian product of graphs corresponds to the funny tensor product of categories. The cartesian product of graphs is one of two graph products that turn the category of graphs and graph homomorphisms into a symmetric closed monoidal category (as opposed to merely symmetric monoidal), the other being the tensor product of graphs. The internal hom $[G,H]$ for the cartesian product of graphs has graph homomorphisms from $G$ to $H$ as vertices and "unnatural transformations" between them as edges.

## History

According to Imrich & Klavžar (2000), Cartesian products of graphs were defined in 1912 by Whitehead and Russell. They were repeatedly rediscovered later, notably by Gert Sabidussi (1960).