A Bit of History
Boris Weisfeiler and Andrey Leman published this algorithm in 1968 as a practical heuristic for the graph isomorphism problem previewed in Part 18 — decades before Babai's 2015 quasipolynomial breakthrough, and long before anyone could have predicted its second life. That second life arrived once graph neural networks (Part 26) became widespread: researchers proved that the message-passing architecture underlying essentially every mainstream GNN can never distinguish two graphs the 1-dimensional Weisfeiler-Leman test itself cannot distinguish — turning a 50-year-old isomorphism heuristic into the precise mathematical ceiling on modern deep learning's graph-reasoning power.
Working Principle: Color Refinement
The 1-dimensional Weisfeiler-Leman algorithm (often called simply "color refinement") is disarmingly close in spirit to the message-passing framework from Part 26:
- Assign every vertex the same initial "color" (or, in the labeled-graph case, its own label).
- Refine: simultaneously recompute every vertex's color as a hash of its current color together with the multiset of its neighbors' current colors — vertices with identical local neighborhoods (in terms of color) get identical new colors; vertices with even slightly different neighborhoods get different new colors.
- Repeat step 2 until the partition of vertices into color classes stops changing (guaranteed to happen within \(V\) rounds).
- Two graphs are declared possibly isomorphic if their final color-class multisets match exactly; if the multisets differ, the graphs are certainly non-isomorphic.
Key Insight
"Aggregate the multiset of neighbor states, then update" is exactly the message-passing recipe from Part 26's graph neural network deep dive — this is not a coincidence. It is a theorem: any GNN built purely from order-independent neighborhood aggregation can never be more discriminative than 1-WL color refinement, since both are fundamentally doing the same local-neighborhood-hashing computation, just with learned (GNN) versus fixed (WL) hash functions.
Worked Example
On two 6-vertex graphs that are not isomorphic but happen to be locally indistinguishable everywhere (a specific pair of 3-regular graphs constructed precisely to fool color refinement), every vertex in both graphs converges to the exact same final color after refinement stabilizes — 1-WL incorrectly reports "possibly isomorphic" on a pair that is provably not. This isn't a bug in the algorithm's implementation; it's a fundamental limitation of the test itself, and such graph pairs are the standard textbook example used to demonstrate 1-WL's real expressive ceiling.
Correctness & Its Limits
The algorithm is a one-directional test: if the final color-class multisets differ, the graphs are guaranteed non-isomorphic (a sound, reliable negative result), but if the multisets match, the graphs might still be non-isomorphic — 1-WL cannot distinguish certain genuinely different graphs, most famously all pairs of regular graphs with the same degree (since every vertex already has an identical initial neighborhood-multiset by symmetry, refinement can never break the tie). Higher-dimensional generalizations (\(k\)-WL, considering tuples of \(k\) vertices at once rather than single vertices) are strictly more powerful for larger \(k\), forming an infinite hierarchy of increasingly expressive (and increasingly expensive) isomorphism tests.
Complexity Analysis
Each refinement round touches every edge once, and the number of rounds needed is bounded by the number of vertices (since the number of distinct color classes strictly increases each round it changes, up to a maximum of \(V\)):
$$\text{Time: } O(VE) \qquad \text{(naive bound; } O(E\log V) \text{ achievable with careful bucket-based refinement)}$$
Fast enough to run as a cheap, reliable "no" filter before attempting expensive exact isomorphism algorithms — most practical isomorphism-checking pipelines run 1-WL first, only falling back to slower exact methods when 1-WL fails to rule out isomorphism.
Implementation
Real-World Applications
Designing More Expressive Graph Neural Networks
Since standard message-passing GNNs are provably no more powerful than 1-WL, machine learning researchers now design deliberately "WL-beyond" architectures — adding higher-order tuple-based reasoning, positional/structural features, or subgraph-counting components specifically to exceed the 1-WL expressiveness ceiling — and directly benchmark new GNN architectures by testing them against the exact graph pairs known to fool 1-WL, using this 1968 algorithm as the field's standard yardstick for "how expressive is this new model, really."
Exercises
- Run color refinement by hand on two small triangles (3-cycles) versus one 6-cycle, and verify the algorithm correctly distinguishes them as non-isomorphic.
- Explain why 1-WL can never distinguish two different regular graphs with the same degree, using the "identical initial neighborhood multiset" argument.
- Connect the color-refinement update rule directly to the message-passing update rule from Part 26 — which parts of each algorithm correspond to each other?
- Challenge: Research the specific pair of 3-regular graphs commonly used to demonstrate 1-WL's limitation (sometimes called the "CFI graphs" or similar constructions) and explain informally why they fool the test.
Limitations
A Heuristic, Not a Decision Procedure
1-WL is not a complete isomorphism test — a "possibly isomorphic" verdict is not a guarantee, only the absence of a distinguishing signal. It fails outright on all regular graphs of the same degree, and by extension, any GNN architecture relying purely on 1-WL-equivalent message passing inherits this exact same blind spot, regardless of how much training data or model capacity is thrown at it — a genuine architectural ceiling, not merely a training limitation.