Learning Long Range Dependencies on Graphs via Random Walks

Dexiong Chen, Till Hendrik Schulz, Karsten M. Borgwardt

TL;DR

NeuralWalker is a new graph learning architecture that captures long-range dependencies by treating random walks as sequences and processing them with state-of-the-art sequence models like Mamba. By combining the "depth-first" exploration of random walks with the "breadth-first" nature of local message passing, it achieves state-of-the-art results across 19 benchmarks, including massive performance jumps of up to 13% on long-range tasks.

What Problem Does This Paper Address?

Graph learning currently faces a "Goldilocks" problem. On one hand, standard Message-Passing Neural Networks (GNNs) are excellent at understanding a node's immediate neighborhood but struggle with "distant" interactions. As you add more layers to reach further, they suffer from over-smoothing (features become indistinguishable) or over-squashing (information bottlenecks).

On the other hand, Graph Transformers (GTs) offer global reach through attention mechanisms. However, they often treat the graph as a "bag of nodes" supplemented by positional encodings. This approach can oversimplify the graph's actual topology, losing the rich structural nuances that define how nodes are truly connected across long paths.

The authors seek a middle ground: a model that can "see" across the whole graph without losing the structural "connect-the-dots" information.

Methods

The authors introduce NeuralWalker, a framework that alternates between random walk exploration and local message passing. The core innovation lies in how it handles random walks:

  1. Random Walk Sampler: It generates a set of non-backtracking random walks. Unlike standard walks, these don't immediately return to the node they just left, forcing the model to explore further.
  2. Walk Embedder: Each step in the walk is embedded using node and edge features, plus specialized positional encodings (Identity and Adjacency encodings) that track if a node has been visited before in that specific walk.
  3. The Sequence Layer: This is the "brain" of the model. Instead of using simple aggregations, the authors treat the walk as a literal sequence. They tested CNNs, Transformers, and State Space Models (SSMs) like Mamba. Mamba proved superior because it scales linearly with sequence length while effectively capturing long-range dependencies.
  4. Walk Aggregator: The processed walk features are pooled back into the nodes.
  5. Hybrid Architecture: These walk-based blocks are interleaved with standard GNN layers (like GIN) to ensure the model doesn't lose the ability to capture local sub-structures (like star-shaped subgraphs) that random walks might miss.

Datasets

The model was evaluated on a massive suite of 19 datasets:

  • GNN Benchmarks: ZINC (molecular graphs), MNIST, CIFAR10, PATTERN, and CLUSTER.
  • Long-Range Graph Benchmark (LRGB): Specifically designed to test distant dependencies, including PascalVoc-SP and COCO-SP (image-to-graph tasks), and Peptides-func/struct.
  • Open Graph Benchmark (OGB): Large-scale datasets like Molpcba, PPA, and Code2.
  • Node Classification: Several transductive tasks including the massive Pokec social network dataset (1.6 million nodes).

Key Insights and Ideas

  • Mamba > Transformers for Graphs: Surprisingly, Transformers were suboptimal for processing walks. The authors suggest that the specific sequential nature of a path through a graph is better captured by the recurrent-like dynamics of SSMs (Mamba) than by the global attention of a Transformer.
  • Theoretical Expressivity: The authors prove that NeuralWalker is strictly more expressive than the standard 1-WL (Weisfeiler-Lehman) isomorphism test. It can distinguish complex graph structures that traditional GNNs find identical.
  • Scalability via Sampling: Because the complexity of the walk layer depends on the number and length of walks rather than the total number of nodes/edges, the model is highly scalable. They successfully processed the 1.6M-node Pokec dataset on a single GPU.
  • Pretraining Potential: By treating walks as sequences, the authors successfully adapted BERT-style "Masked Positional Encoding" pretraining, which significantly boosted performance on molecular tasks like ZINC.

Key Results

NeuralWalker set new state-of-the-art (SOTA) records on a wide variety of tasks:

  • LRGB Dominance: It outperformed existing baselines by 10% on PascalVoc-SP and 13% on COCO-SP. These are massive improvements in a field where gains are usually measured in fractions of a percent.
  • Molecular Accuracy: On the ZINC dataset, it achieved a Mean Absolute Error (MAE) of 0.053, outperforming both specialized GNNs and heavy-duty Graph Transformers.
  • Efficiency: Despite its power, it remains computationally practical. For instance, it achieved SOTA-level performance on node classification while avoiding the quadratic memory costs of standard Transformers.

Limitations and Future Work

  • Sampling Strategy: While random walks are effective, the authors acknowledge they haven't yet found the "optimal" way to sample. Purely random walks might over-sample certain dense areas of a graph while ignoring others.
  • Long-Range Dataset Scarcity: The authors noted that many current "benchmarks" don't actually require long-range reasoning. Only a few datasets (like LRGB) truly pushed the model's unique capabilities.
  • Future Directions: The team suggests exploring more sophisticated self-supervised learning on walks and developing more efficient sampling techniques to ensure even better graph coverage with fewer walks.

Summary updated

BibTeX
@inproceedings{chen2025learning,
  author = {Dexiong Chen and Till Hendrik Schulz and Karsten M. Borgwardt},
  title = {{Learning Long Range Dependencies on Graphs via Random Walks}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=kJ5H7oGT2M},
}
Figure