The Weisfeiler-Lehman Distance: Reinterpretation and Connection with GNNs

Samantha Chen, Sunhyuk Lim, Facundo Mémoli, Zhengchao Wan, Yusu Wang · OpenReview

Abstract

In this paper, we present a novel interpretation of the so-called Weisfeiler-Lehman (WL) distance, introduced by Chen et al. (2022), using concepts from stochastic processes. The WL distance aims at comparing graphs with node features, has the same discriminative power as the classic Weisfeiler-Lehman graph isomorphism test and has deep connections to the Gromov-Wasserstein distance. This new interpretation connects the WL distance to the literature on distances for stochastic processes, which also makes the interpretation of the distance more accessible and intuitive. We further explore the connections between the WL distance and certain Message Passing Neural Networks, and discuss the implications of the WL distance for understanding the Lipschitz property and the universal approximation results for these networks.

Introduction

Graph Neural Networks (GNNs) are the workhorses of modern geometric deep learning, yet understanding their theoretical limits has historically relied on the Weisfeiler-Lehman (WL) isomorphism test. While the WL test is excellent for determining if two graphs are non-isomorphic, it is a discrete "pass/fail" test that does not quantify the degree of difference between graphs.

To address this, recent research introduced the WL distance, a continuous metric that provides a geometric framework for the WL test. However, the original definition was mathematically complex and difficult to apply to GNN analysis. This paper bridges that gap by providing a cleaner, stochastic interpretation of the WL distance and using it to establish fundamental properties of GNNs: stability and expressivity.

Methods: A Stochastic Perspective

The authors move away from the iterative measure-aggregation of the original WL distance, instead employing the language of stochastic processes.

Markovian Couplings

Graphs are treated as Markov chains where nodes are states and edges represent transition probabilities. The WL distance is re-envisioned as the cost of "coupling" two random walks—essentially trying to pair up trajectories on two different graphs such that the distance between their node labels is minimized.

Visualization of trajectory coupling between two stochastic processes.

Causal Optimal Transport (COT)

The paper establishes a formal link to COT. In standard Optimal Transport, one examines the entire distribution at once. In Causal OT, the matching of points at time $t$ cannot depend on future states at time $t+1$. The authors prove that the WL distance is exactly equivalent to a bicausal optimal transport problem between path distributions.

The cost function between paths X and Y at time k in the context of Causal Optimal Transport.

GNN Theoretical Framework

A specific class of $k$-layer Message Passing GNNs (MP-GNNs) is defined, showing how their "aggregate and update" steps mathematically mirror the kernels used in the WL distance.

Key Insights and Ideas

  • The Role of Causality: The iterative nature of the WL test (where labels at step $k$ depend only on labels at $k-1$) is perfectly captured by the "causality" constraint in Optimal Transport. This makes the WL distance a natural fit for analyzing processes that evolve step-by-step, like GNNs.
  • Stability and Lipschitz Continuity: By proving that MP-GNNs are Lipschitz continuous with respect to the WL distance, the authors show that GNNs are inherently stable. Small perturbations to a graph (resulting in a small WL distance) lead to only minor changes in GNN output.
  • Universal Approximation: The paper proves that MP-GNNs can approximate any continuous function on a compact set of graphs, provided continuity is defined by the WL distance. This provides a rigorous foundation for using GNNs in complex regression and classification tasks.
  • Simplifying the Mathematics: Reframing the distance in terms of random walks makes a previously dense metric accessible to researchers familiar with basic Markov chains.

Key Results

  • Equivalence Theorem: Proved that the WL distance of depth $k$ is equal to the bicausal optimal transport distance between $k$-step path distributions.
  • Discriminative Power: Confirmed that a restricted class of MP-GNNs (even with 1D hidden layers) has the same power to distinguish graphs as the WL distance.
  • Lipschitz Property: Established a concrete bound for GNN stability: $|h(G_1) - h(G_2)| \leq C \cdot d_{WL}^{(k)}(G_1, G_2)$, where $C$ depends on the Lipschitz constants of the GNN's activation functions.
  • Universal Approximation: Formally proved that the family of $k$-layer MP-GNNs is dense in the space of continuous functions over compact graph subspaces.

Limitations and Future Work

While the reinterpretation is intuitive, calculating Causal Optimal Transport remains computationally expensive. Future work could leverage "Sinkhorn-style" algorithms to accelerate WL distance calculations. Additionally, the current framework assumes graphs share the same label space; the COT connection might eventually help extend the WL distance to compare graphs with heterogeneous node features. Finally, some results require injective label functions, which may not hold in all practical applications.

Summary updated

Abstract

In this paper, we present a novel interpretation of the so-called Weisfeiler-Lehman (WL) distance, introduced by Chen et al. (2022), using concepts from stochastic processes. The WL distance aims at comparing graphs with node features, has the same discriminative power as the classic Weisfeiler-Lehman graph isomorphism test and has deep connections to the Gromov-Wasserstein distance. This new interpretation connects the WL distance to the literature on distances for stochastic processes, which also makes the interpretation of the distance more accessible and intuitive. We further explore the connections between the WL distance and certain Message Passing Neural Networks, and discuss the implications of the WL distance for understanding the Lipschitz property and the universal approximation results for these networks.
BibTeX
@inproceedings{chen2023weisfeiler,
  author = {Samantha Chen and Sunhyuk Lim and Facundo Mémoli and Zhengchao Wan and Yusu Wang},
  title = {{The Weisfeiler-Lehman Distance: Reinterpretation and Connection with GNNs}},
  booktitle = {TAG-ML},
  year = {2023},
  url = {https://openreview.net/forum?id=1ga2JwVVpF},
}
Figure