Towards a practical k-dimensional Weisfeiler-Leman algorithm

Christopher Morris, Petra Mutzel

Abstract

Graph kernels based on the 1-dimensional Weisfeiler-Leman (1-WL) algorithm and corresponding neural architectures have recently emerged as powerful tools for supervised learning with graphs. However, due to the purely local nature of these algorithms, they often miss essential structural patterns. The $k$-dimensional Weisfeiler-Leman ($k$-WL) algorithm addresses this by considering $k$-tuples of vertices, accounting for higher-order interactions. Unfortunately, standard $k$-WL does not scale well and is prone to overfitting. In this work, we propose local variants and corresponding neural architectures ($\delta$-$k$-LGNN) that consider a subset of the original neighborhood, making them more scalable and less prone to overfitting. We prove that the expressive power of our $\delta$-$k$-LWL$^+$ algorithm is strictly higher than the original $k$-WL. Experimental results confirm that our local algorithms lead to vastly reduced computation times and prevent overfitting, establishing new state-of-the-art results for graph classification and promising performance on molecular regression tasks.

Introduction

Standard Graph Neural Networks (GNNs) typically operate by aggregating information from a node's immediate neighbors, a process analogous to the 1-WL isomorphism test. While efficient, this approach is "near-sighted" and fails to capture complex higher-order structures like rings or cliques, which are vital in domains such as chemistry. Higher-order $k$-WL algorithms solve this by considering groups of $k$ nodes, but their traditional global implementation—where every tuple is compared against every other node in the graph—results in poor scalability and a tendency to overfit by memorizing exact graph structures too quickly.

Localizing the Weisfeiler-Leman Algorithm

We propose local, sparsity-aware variants of the $k$-WL algorithm, specifically $\delta$-$k$-LWL and $\delta$-$k$-LWL$^+$. Instead of the dense, global updates used in standard $k$-WL, these local variants only aggregate information from nodes that are physically adjacent to the vertices within a given $k$-tuple. This approach leverages the natural sparsity of real-world graphs, such as molecules, where distant atoms rarely have direct local chemical interactions.

Theoretical Expressivity

A significant finding of our work is that restricting the algorithm to local neighborhoods does not diminish its power. In fact, we mathematically prove that $\delta$-$k$-LWL$^+$ is strictly more powerful than the standard global $k$-WL algorithm at distinguishing non-isomorphic graphs. This counterintuitive result arises because the local variant can more effectively track specific neighbor counts, allowing it to distinguish complex graph pairs that stump the global version.

Figure 1: Hierarchy of expressive power between various WL variants and GNN architectures.

Experimental Evaluation

We evaluated our methods across a wide range of benchmarks, including small-to-medium graph classification and large-scale molecular regression.

Kernel Performance and Scalability

The local kernels demonstrated massive speedups and improved accuracy over global baselines. On the ENZYMES dataset, the $\delta$-2-LWL kernel was over 10x faster than the global $\delta$-2-WL. Furthermore, the local variants set new state-of-the-art records on several datasets, including IMDB-MULTI, NCI1, NCI109, and PROTEINS.

Figure 2: Classification accuracy comparison across benchmark datasets. Local variants (bottom rows) consistently outperform global and baseline methods.

Overcoming Overfitting

Global $k$-WL algorithms often suffer from severe overfitting. For example, on the ENZYMES dataset, the global $\delta$-2-WL reaches a training accuracy of 91.2% but only 37.5% on the test set. By forcing information to propagate more slowly across the graph, our local variants act as a natural regularizer. The $\delta$-2-LWL variant achieved a significantly higher test accuracy of 56.6%, demonstrating much better generalization.

Neural Architectures for Molecular Regression

Our local algorithm translates effectively into a differentiable GNN architecture, the $\delta$-$k$-LGNN. On the QM9 molecular regression dataset, the sparse $\delta$-2-LGNN achieved a Mean Absolute Error (MAE) of 0.029, significantly outperforming previous dense higher-order networks like 3-IGN (0.046) and 1-2-3-GNN (0.062).

Conclusion

By introducing local neighborhood aggregation, we have developed a higher-order graph learning framework that is simultaneously more expressive, more scalable, and more resistant to overfitting than standard $k$-WL. While the $O(n^k)$ complexity for tuple instantiation remains a challenge for massive social networks, these local variants provide a practical and powerful solution for medium-sized graphs like those found in chemistry and biology.

Summary updated

Abstract

Graph kernels based on the $1$-dimensional Weisfeiler-Leman algorithm and corresponding neural architectures recently emerged as powerful tools for (supervised) learning with graphs. However, due to the purely local nature of the algorithms, they might miss essential patterns in the given data and can only handle binary relations. The $k$-dimensional Weisfeiler-Leman algorithm addresses this by considering $k$-tuples, defined over the set of vertices, and defines a suitable notion of adjacency between these vertex tuples. Hence, it accounts for the higher-order interactions between vertices. However, it does not scale and may suffer from overfitting when used in a machine learning setting. Hence, it remains an important open problem to design WL-based graph learning methods that are simultaneously expressive, scalable, and non-overfitting. Here, we propose local variants and corresponding neural architectures, which consider a subset of the original neighborhood, making them more scalable, and less prone to overfitting. The expressive power of (one of) our algorithms is strictly higher than the original algorithm, in terms of ability to distinguish non-isomorphic graphs. Our experimental study confirms that the local algorithms, both kernel and neural architectures, lead to vastly reduced computation times, and prevent overfitting. The kernel version establishes a new state-of-the-art for graph classification on a wide range of benchmark datasets, while the neural version shows promising performance on large-scale molecular regression tasks.
BibTeX
@inproceedings{morris2020towards,
  author = {Christopher Morris and Petra Mutzel},
  title = {{Towards a practical k-dimensional Weisfeiler-Leman algorithm}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
  url = {https://openreview.net/forum?id=eOnAMqiUyJ1},
}
Figure