Graph neural networks extrapolate out-of-distribution for shortest paths
Not on the map. Why?
Abstract (arXiv)
Neural networks (NNs), despite their success and wide adoption, still struggle to extrapolate out-of-distribution (OOD), i.e., to inputs that are not well-represented by their training dataset. Addressing the OOD generalization gap is crucial when models are deployed in environments significantly different from the training set, such as applying Graph Neural Networks (GNNs) trained on small graphs to large, real-world graphs. One promising approach for achieving robust OOD generalization is the framework of neural algorithmic alignment, which incorporates ideas from classical algorithms by designing neural architectures that resemble specific algorithmic paradigms (e.g. dynamic programming). The hope is that trained models of this form would have superior OOD capabilities, in much the same way that classical algorithms work for all instances. We rigorously analyze the role of algorithmic alignment in achieving OOD generalization, focusing on graph neural networks (GNNs) applied to the canonical shortest path problem. We prove that GNNs, trained to minimize a sparsity-regularized loss over a small set of shortest path instances, exactly implement the Bellman-Ford (BF) algorithm for shortest paths. In fact, if a GNN minimizes this loss within an error of ε, it implements the BF algorithm with an error of O(ε). Consequently, despite limited training data, these GNNs are guaranteed to extrapolate to arbitrary shortest-path problems, including instances of any size. Our empirical results support our theory by showing that NNs trained by gradient descent are able to minimize this loss and extrapolate in practice.
Key facts. Cited by 10 papers in the map (data through 13 Oct 2026). Builds on 33 of its 39 references that are in the map. First posted on arXiv 24 Mar 2025.
Builds on
33 of 39 references.
References · 33
- 2017Inductive Representation Learning on Large Graphscited by 6,303
- 2017Neural Message Passing for Quantum Chemistrycited by 3,471
- 2019A Comprehensive Survey on Graph Neural Networkscited by 2,911
- 2018Graph Neural Networks: A Review of Methods and Applicationscited by 1,574
- 2017MoleculeNet: A Benchmark for Molecular Machine Learningcited by 1,043
- 2020Learning to Simulate Complex Physics with Graph Networkscited by 873
- 2017Learning Combinatorial Optimization Algorithms over Graphscited by 557
- 2021Towards Out-Of-Distribution Generalization: A Surveycited by 432
- 2021Combinatorial optimization and reasoning with graph neural networkscited by 267
- 2022Transformers Learn Shortcuts to Automatacited by 261
- 2020How Neural Networks Extrapolate: From Feedforward to Graph Neural Networkscited by 219
- 2019What graph neural networks cannot learn: depth vs widthcited by 198
21 more
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2019What Can Neural Networks Reason About?cited by 158
- 2020From Local Structures to Size Generalization in Graph Neural Networkscited by 120
- 2019Neural Execution of Graph Algorithmscited by 118
- 2020Erdos Goes Neural: an Unsupervised Learning Framework for Combinatorial Optimization on Graphscited by 115
- 2022The CLRS Algorithmic Reasoning Benchmarkcited by 103
- 2021Neural Algorithmic Reasoningcited by 93
- 2022Domain-Adjusted Regression or: ERM May Already Learn Features Sufficient for Out-of-Distribution Generalizationcited by 69
- 2019Approximation Ratios of Graph Neural Networks for Combinatorial Problemscited by 68
- 2023Length Generalization in Arithmetic Transformerscited by 65
- 2022Theory of Graph Neural Networks: Representation and Learningcited by 61
- 2022Graph Neural Networks are Dynamic Programmerscited by 55
- 2020Learning Algebraic Multigrid Using Graph Neural Networkscited by 54
- 2023A graphon-signal analysis of graph neural networkscited by 29
- 2023Limits, approximation and size transferability for GNNs on sparse graphs via graphopscited by 17
- 2023Asynchronous Algorithmic Alignment with Cocyclescited by 13
- 2024Recurrent Aggregators in Neural Algorithmic Reasoningcited by 6
- 2022Learning Graph Algorithms With Recurrent Graph Neural Networkscited by 5
- 2025Subsampling Graphs with GNN Performance Guaranteescited by 4
- 2024Help Me Help You: The Aggregate Value of Source and Target Data in Transfer Learningcited by 3
- 2024Accelerating data-driven algorithm selection for combinatorial partitioning problemscited by 2
Built on by
Citing papers per year: 2025: 4; 2026: 6.
10 papers.
- 2025Optimizers Qualitatively Alter Solutions And We Should Leverage Thiscited by 17
- 2025Quantitative Bounds for Length Generalization in Transformerscited by 8
- 2025A Logical View of GNN-Style Computation and the Role of Activation Functionscited by 3
- 2025Automated discovery of finite volume schemes using Graph Neural Networkscited by 0
- 2026Neural Algorithmic Reasoning for Approximate k-Coloring with Recursive Warm Startscited by 0
- 2026Learning to Approximate Uniform Facility Location via Graph Neural Networkscited by 0
- 2026MINAR: Mechanistic Interpretability for Neural Algorithmic Reasoningcited by 0
- 2026Towards Distillation Guarantees under Algorithmic Alignment for Combinatorial Optimizationcited by 0
- 2026From Shortcut Learning to Discrete Neural Insertion Sortcited by 0
- 2026Neural Algorithmic Reasoning for Graph Saddle Point Problemscited by 0
- 2026Neural Algorithmic Reasoning for Graph Saddle Point Problems5 Oct 2026
- 2026From Shortcut Learning to Discrete Neural Insertion Sort25 Sep 2026
- 2026Towards Distillation Guarantees under Algorithmic Alignment for Combinatorial Optimization19 May 2026
- 2026MINAR: Mechanistic Interpretability for Neural Algorithmic Reasoning24 Feb 2026
- 2026Learning to Approximate Uniform Facility Location via Graph Neural Networks13 Feb 2026
- 2026Neural Algorithmic Reasoning for Approximate k-Coloring with Recursive Warm Starts8 Jan 2026
- 2025A Logical View of GNN-Style Computation and the Role of Activation Functions22 Dec 2025
- 2025Quantitative Bounds for Length Generalization in Transformers30 Oct 2025
- 2025Automated discovery of finite volume schemes using Graph Neural Networks26 Aug 2025
- 2025Optimizers Qualitatively Alter Solutions And We Should Leverage This16 Jul 2025