Explaining graph isomorphism complexity and Weisfeiler-Lehman test
The graph isomorphism (GI) complexity class contains problems polynomial-time reducible to the graph isomorphism problem, which asks if two graphs are isomorphic. GI lies between P and NP—it’s in NP but not known to be NP-complete or in P, with a quasipolynomial-time algorithm from Babai (2015). GI is also in classes like SPP and coAM and is believed unlikely to be NP-complete since that would collapse the polynomial hierarchy. The Weisfeiler-Lehman (WL) color refinement is a heuristic for GI that iteratively refines node colors based on neighbors, stabilizing after at most n steps; differing color patterns prove non-isomorphism, but identical patterns don’t guarantee isomorphism. Extensions like k-WL increase distinguishing power.
One of the standard decision problems in finite model theory and complexity theory is the graph isomorphism problem:
given two finite graphs (G) and (H) on (n) labelled vertices, decide whether there is a bijection (\pi:V(G)\to V(H)) such that ({u,v}\in E(G)) if and only if ({\pi(u),\pi(v)}\in E(H)).
The language
[
\mathsf{GI}={,\langle G,H\rangle : G \cong H\ }
]
is clearly in (\mathsf{NP}): an isomorphism (\pi) is a polynomial‑size certificate that can be checked in polynomial time. There is no known polynomial–time algorithm for it in general, and there is good evidence that it is not (\mathsf{NP})-complete: if (\mathsf{GI}) were (\mathsf{NP})-complete under the usual reductions then the polynomial–time hierarchy would collapse to its second level. On the other hand, (\mathsf{GI}) is contained in a number of low–level classes such as (\mathsf{SPP}) and (\mathsf{coAM}), and Babai’s 2015 breakthrough gives a quasi‑polynomial‑time algorithm.
It is convenient to define the corresponding complexity class (\mathbf{GI}) as the set of all decision problems that are reducible to graph isomorphism in polynomial time (under many–one or Turing reductions, depending on the author). Problems such as testing isomorphism of finite automata, of certain classes of relational structures, or of partially ordered sets are (\mathbf{GI})–complete. This class sits between (\mathsf{P}) and (\mathsf{NP}) as far as current knowledge goes.
Because of the lack of a general polynomial algorithm, a variety of combinatorial heuristics are used in practice to distinguish non‑isomorphic graphs quickly. One of the most widely studied is the Weisfeiler–Lehman color refinement. In its simplest, 1‑dimensional form it works as follows:
- Start with an initial coloring (c_0) of the vertices. If no labels are present, all vertices can be given the same color, or they can be colored by degree.
- At round (i+1), assign to each vertex (v) a new color
[
c_{i+1}(v) = \mathrm{hash}\bigl(c_i(v),\ \multiset{,c_i(u)\mid u\in N(v),}\bigr),
]
i.e. a code that depends on its current color and the multiset of colors of its neighbours.
- Repeat until the coloring stabilises: no further refinements occur.
This iterative refinement runs in (O(n^2)) time and always reaches a stable partition in at most (n) steps. If, at some stage, the multisets of colors or the counts of each color differ between (G) and (H), then the graphs cannot be isomorphic. If the process stabilises with the same color multiset on both graphs, the test is inconclusive: there are non‑isomorphic graphs that 1‑WL fails to distinguish. Higher–dimensional versions of the Weisfeiler–Lehman test, which refine colors on (k)‑tuples of vertices, are strictly more powerful and form the basis of the best practical isomorphism algorithms.