Which Algorithms Can Graph Neural Networks Learn?
Solveig Wittig, Antonis Vasileiou, Robert R. Nerem, Timo Stoll, Floris Geerts, Yusu Wang, Christopher Morris
Abstract
In recent years, there has been growing interest in understanding neural architectures' ability to learn to execute discrete algorithms, a line of work often referred to as neural algorithmic reasoning. The goal is to integrate algorithmic reasoning capabilities into larger neural pipelines. Many such architectures are based on (message-passing) graph neural networks (MPNNs), owing to their permutation equivariance and ability to deal with sparsity and variable-sized inputs. However, existing work is either largely empirical and lacks formal guarantees or it focuses solely on expressivity, leaving open the question of when and how such architectures generalize beyond a finite training set. In this work, we propose a general theoretical framework that characterizes the sufficient conditions under which MPNNs can learn an algorithm from a training set of small instances and provably approximate its behavior on inputs of arbitrary size. Our framework applies to a broad class of algorithms, including single-source shortest paths, minimum spanning trees, and general dynamic programming problems, such as the 0-1 knapsack problem. In addition, we establish impossibility results for a wide range of algorithmic tasks, showing that standard MPNNs cannot learn them, and we derive more expressive MPNN-like architectures that overcome these limitations. Finally, we refine our analysis for the Bellman-Ford algorithm, yielding a substantially smaller required training set and significantly extending the recent work of Nerem et al. [2025] by allowing for a differentiable regularization loss. Empirical results largely support our theoretical findings.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 8b8da1c4-40cd-4b66-88e0-a81af3bf19d2Cited by top-tier papers1
Ask how each one uses itBuilds on52
- Neural Bellman-Ford Networks: A General Graph Neural Network Framework for Link PredictionZhaocheng Zhu, Zuobai Zhang, Louis-Pascal A. C. Xhonneux, Jian TangNeurIPS 2021 · 546 citations
- Can Graph Neural Networks Count Substructures?Zhengdao Chen, Lei Chen, Soledad Villar, Joan BrunaNeurIPS 2020 · 392 citations
- Distance Encoding: Design Provably More Powerful Neural Networks for Graph Representation LearningPan Li, Yanbang Wang, Hongwei Wang, Jure LeskovecNeurIPS 2020 · 391 citations
- Generalization and Representational Limits of Graph Neural NetworksVikas K. Garg, Stefanie Jegelka, Tommi S. JaakkolaICML 2020 · 363 citations
- What graph neural networks cannot learn: depth vs widthAndreas LoukasICLR 2020 · 336 citations
Related papers
- Graph Neural Networks are Dynamic ProgrammersAndrew Joseph Dudzik, Petar VelickovicNeurIPS 2022 · 82 citations
- Neural Execution of Graph AlgorithmsPetar Velickovic, Rex Ying, Matilde Padovano, Raia Hadsell et al.ICLR 2020 · 192 citations
- What Can Neural Networks Reason About?Keyulu Xu, Jingling Li, Mozhi Zhang, Simon S. Du et al.ICLR 2020 · 281 citations
- Primal-Dual Neural Algorithmic ReasoningYu He, Ellen VitercikICML 2025
- Learning to Execute Graph Algorithms Exactly with Graph Neural NetworksMuhammad Fetrat Qharabagh, Artur Back de Luca, George Giapitzakis, Kimon FountoulakisICML 2026
