NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Distance-Restricted Folklore Weisfeiler-Leman GNNs with Provable Cycle Counting Power

Junru Zhou, Jiarui Feng, Xiyuan Wang, Muhan Zhang

Abstract

Standard Message Passing Neural Networks (MPNNs) are fundamentally limited by their inability to distinguish complex graph structures, such as cycles, which are critical in domains like molecular chemistry. While higher-order Weisfeiler-Leman (WL) algorithms offer greater expressive power, their computational cost is often prohibitive for large-scale applications. This paper, presented at NeurIPS 2023, introduces the $d$-Distance-Restricted Folklore Weisfeiler-Leman ($d$-DRFWL(2)) GNN. By restricting the powerful Folklore WL algorithm to local node neighborhoods, the authors achieve a model that can provably count cycles up to length 6 while maintaining the scalability required for real-world molecular datasets.

Introduction

Graph Neural Networks (GNNs) have become the standard for learning on graph-structured data. However, most popular architectures are no more powerful than the 1-dimensional Weisfeiler-Leman (1-WL) isomorphism test. This "structural blindness" means they cannot distinguish between graphs that have different cycle arrangements if their local tree-like neighborhoods are identical. In fields like organic chemistry, where the presence of specific rings (e.g., benzene) determines a molecule's properties, this limitation is a significant hurdle.

To address this, researchers have explored higher-order WL methods or Subgraph GNNs. However, these methods typically suffer from $O(n^3)$ complexity or higher, making them impractical for large datasets. The $d$-DRFWL(2) framework addresses this gap by exploiting the inherent locality of structural features.

Methodology: Distance-Restricted Folklore WL

The authors base their approach on the 2-dimensional Folklore Weisfeiler-Leman (FWL(2)) algorithm. Unlike standard GNNs that update node features, FWL(2) operates on pairs of nodes $(u, v)$. While highly expressive, updating all $n^2$ pairs in a graph is computationally expensive.

The $d$-DRFWL(2) Approach

The core innovation is the introduction of a distance restriction. The model only tracks and updates features for node pairs $(u, v)$ where the shortest path distance between them is at most $d$. This leads to several key advantages:

  1. Sparsity Exploitation: By ignoring pairs beyond distance $d$, the model focuses on local structural information and ignores distant "noise."
  2. Efficient Message Passing: A pair $(u, v)$ updates its state by aggregating information from intermediate nodes $w$ that form "triangles" of distances with $u$ and $v$. This mimics the FWL(2) mechanism but within a constrained search space.
  3. Reduced Complexity: For sparse graphs (like molecules), the space complexity is reduced to $O(n \cdot \text{deg}^2)$ and time complexity to $O(n \cdot \text{deg}^4)$, where "deg" is the average degree. This is a significant improvement over the $O(n^3)$ requirements of traditional high-order methods.

The "Magic" of $d=2$

A pivotal theoretical contribution of this work is the proof that $d=2$ is a critical threshold for chemical applications. Although a 6-cycle (like a benzene ring) has a diameter of 3, the authors demonstrate that tracking pairs at distance $d \leq 2$ is sufficient to provably count cycles up to length 6. This is because the FWL(2) update mechanism allows distance-2 pairs to effectively "sense" the closed walks that constitute 6-cycles. This finding allows the model to hit a "sweet spot" between computational efficiency and the structural intelligence required for organic chemistry.

Experimental Results

The authors evaluated the $d$-DRFWL(2) model across several benchmarks to test its counting power, predictive accuracy, and scalability.

Cycle Counting and Discriminative Power

On synthetic datasets, the 2-DRFWL(2) model achieved near-zero error (MAE < 0.01) when counting 3, 4, 5, and 6-cycles. It also demonstrated superior performance on discriminative benchmarks like EXP, SR25, and BREC, which are specifically designed to test the limits of GNN expressivity.

Molecular Property Prediction

On the QM9 dataset (130,000 small molecules), the model achieved state-of-the-art or second-best results on 11 out of 12 thermodynamic targets. This confirms that the ability to count cycles translates directly into better physical and chemical property predictions. Similar competitive results were observed on ZINC and various Open Graph Benchmark (OGB) datasets.

Efficiency and Scalability

Compared to other cycle-aware models like $I^2$-GNN, the 2-DRFWL(2) model used 8.5x less GPU memory and was significantly faster to train on QM9. Furthermore, the model successfully scaled to large protein graphs (e.g., ProteinsDB) with approximately 500 nodes, where many higher-order baselines failed due to out-of-memory (OOM) errors.

Limitations

Despite its efficiency on sparse graphs, the $O(n \cdot \text{deg}^4)$ complexity remains a challenge for very dense graphs or social networks containing high-degree "hubs." Additionally, the preprocessing required to identify neighbors for node pairs can be time-consuming, sometimes taking up to 40 seconds per graph in extreme cases.

Conclusion

The $d$-DRFWL(2) GNN represents a significant step forward in balancing theoretical expressivity with practical performance. By proving that local distance restrictions do not sacrifice the ability to identify critical structures like 6-cycles, the authors provide a scalable blueprint for building structurally aware GNNs for chemistry and beyond. Future work may involve optimizing the preprocessing stage and extending distance-restriction principles to even higher-order WL tests.

Summary updated

BibTeX
@inproceedings{zhou2023distance,
  author = {Junru Zhou and Jiarui Feng and Xiyuan Wang and Muhan Zhang},
  title = {{Distance-Restricted Folklore Weisfeiler-Leman GNNs with Provable Cycle Counting Power}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=94rKFkcm56},
}
Figure