The Power of the Weisfeiler-Leman Algorithm for Machine Learning with Graphs

Christopher Morris, Matthias Fey, Nils M. Kriege

Abstract

In recent years, algorithms and neural architectures based on the Weisfeiler-Leman algorithm, a well-known heuristic for the graph isomorphism problem, emerged as a powerful tool for (supervised) machine learning with graphs and relational data. Here, we give a comprehensive overview of the algorithm's use in a machine learning setting. We discuss the theoretical background, show how to use it for supervised graph- and node classification, discuss recent extensions, and its connection to neural architectures. Moreover, we give an overview of current applications and future directions to stimulate research.

Introduction

Machine learning typically requires data to be represented as fixed-length vectors. However, graphs are non-regular structures where the "meaning" is hidden in the connections between nodes. To process them, we need a way to represent a graph's topology and features vectorially.

The core challenge is the Graph Isomorphism Problem: determining if two graphs are structurally identical. If an algorithm cannot distinguish between two different graphs, it cannot learn to treat them differently. This paper addresses the gap between classical graph theory (isomorphism testing) and modern deep learning (GNNs), explaining why certain models fail on simple tasks and how to fix them.

The Weisfeiler-Leman Framework

The paper centers on the 1-dimensional Weisfeiler-Leman (1-WL) algorithm, also known as color refinement. This process involves:

  1. Color Refinement: Nodes start with a label (color). In each iteration, a node's new color is determined by an injective hash of its current color and the multiset of its neighbors' colors.
  2. Graph Kernels: The "WL subtree kernel" creates a feature vector by counting the occurrences of these colors over several iterations.
  3. Neural Equivalence: Standard Graph Neural Networks (GNNs) are essentially a "neural version" of 1-WL. Instead of discrete colors and injective hashes, GNNs use continuous feature vectors and neural network layers (aggregation and update functions) to pass messages.
The 1-WL color refinement process (left) and its neural equivalent in GNNs (right).

Expressivity and the $k$-WL Hierarchy

A landmark insight is that any standard message-passing GNN is at most as powerful as the 1-WL test. For a GNN to reach the full power of 1-WL, its aggregation and update functions must be injective. This explains why certain pooling operations (like sum) are theoretically superior to others (like mean or max) in terms of distinguishing structures.

To move beyond the limitations of 1-WL (which cannot distinguish certain regular graphs, such as two disjoint triangles versus a single hexagon), the paper discusses the $k$-WL hierarchy. This algorithm operates on tuples of $k$ nodes, providing a hierarchy of increasingly powerful structural tests. Researchers are now developing "Provably Powerful GNNs" based on this hierarchy to capture more complex subgraphs.

Empirical Analysis and the Completeness Paradox

Despite the known theoretical failures of 1-WL, the authors perform an empirical analysis of the "completeness ratio"—the ability of 1-WL to distinguish graphs—across several standard benchmark datasets including bioinformatics (MUTAG, PROTEINS) and social networks (IMDB-Binary).

Completeness ratio of WL variants across standard graph datasets, showing that 1-WL is often sufficient for real-world data.

The results demonstrate a "Completeness Paradox": for most real-world benchmark datasets, 1-WL is actually sufficient to distinguish nearly 100% of the graphs. For datasets like NCI1 or PROTEINS, the 1-WL algorithm reaches a completeness ratio of ~1.0 after just a few iterations. This suggests that for current benchmarks, the primary bottleneck might be generalization, rather than structural expressivity.

Conclusion and Future Directions

While we understand the theoretical power of GNNs in terms of structural distinguishability, several challenges remain. A more powerful model (like $k$-WL) might overfit more easily, and large neighborhoods can lead to "over-smoothing." Future work should focus on incorporating domain-specific "expert knowledge" (e.g., functional groups in chemistry) into the WL framework and improving the generalization capabilities of these models.

Summary updated

Abstract

In recent years, algorithms and neural architectures based on the Weisfeiler-Leman algorithm, a well-known heuristic for the graph isomorphism problem, emerged as a powerful tool for (supervised) machine learning with graphs and relational data. Here, we give a comprehensive overview of the algorithm's use in a machine learning setting. We discuss the theoretical background, show how to use it for supervised graph- and node classification, discuss recent extensions, and its connection to neural architectures. Moreover, we give an overview of current applications and future directions to stimulate research.
BibTeX
@inproceedings{morris2021power,
  author = {Christopher Morris and Matthias Fey and Nils M. Kriege},
  title = {{The Power of the Weisfeiler-Leman Algorithm for Machine Learning with Graphs}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.24963/ijcai.2021/618},
}
Figure