Lune

ICLR2025Top-tier venue

Graph Neural Networks Can (Often) Count Substructures

Paolo Pellizzoni, Till Hendrik Schulz, Karsten M. Borgwardt

Abstract

Message passing graph neural networks (GNNs) are known to have limited expressive power in their ability to distinguish some non-isomorphic graphs. Because of this, it is well known that they are unable to detect or count arbitrary graph substructures (i.e., solving the subgraph isomorphism problem), a task that is of great importance for several types of graph-structured data. However, we observe that GNNs are in fact able to count graph patterns quite accurately across several real-world graph datasets. Motivated by this observation, we provide an analysis of the subgraph-counting capabilities of GNNs beyond the worst case, deriving several sufficient conditions for GNNs to be able to count subgraphs and, more importantly, to be able to sample-efficiently learn to count subgraphs. Moreover, we develop novel dynamic programming algorithms for solving the subgraph isomorphism problem on restricted classes of pattern and target graphs, and show that message-passing GNNs can efficiently simulate these dynamic programs. Finally, we empirically validate that our sufficient conditions for GNNs to count subgraphs hold on many real-world datasets, providing a theoretically-grounded explanation to our motivating observations.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • What Expressivity Theory Misses: Message Passing Complexity for GNNs cites What Can Neural Networks Reason About?
  • What Expressivity Theory Misses: Message Passing Complexity for GNNs cites Can Graph Neural Networks Count Substructures?
  • Equivariant Subgraph Aggregation Networks cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
  • Which Algorithms Can Graph Neural Networks Learn? cites What Can Neural Networks Reason About?
  • Which Algorithms Can Graph Neural Networks Learn? cites Equivariant Subgraph Aggregation Networks
  • Which Algorithms Can Graph Neural Networks Learn? cites Can Graph Neural Networks Count Substructures?
  • Can Graph Neural Networks Count Substructures? cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
  • Understanding and Extending Subgraph GNNs by Rethinking Their Symmetries cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
  • Understanding and Extending Subgraph GNNs by Rethinking Their Symmetries cites Equivariant Subgraph Aggregation Networks
  • Understanding and Extending Subgraph GNNs by Rethinking Their Symmetries cites Can Graph Neural Networks Count Substructures?
  • Gelato: Graph Edit Distance via Autoregressive Neural Combinatorial Optimization cites Open Graph Benchmark: Datasets for Machine Learning on Graphs
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. What Expressivity Theory Misses: Message Passing Complexity for GNNsNiklas Kemper, Tom Wollschläger, Stephan GünnemannNeurIPS 2025 · 3 citations
  2. Which Algorithms Can Graph Neural Networks Learn?Solveig Wittig, Antonis Vasileiou, Robert R. Nerem, Timo Stoll et al.ICML 2026
  3. Learning the Neighborhood: Contrast-Free Multimodal Self-Supervised Molecular Graph PretrainingBoshra Ariguib, Mathias Niepert, Andrei ManolacheICML 2026
  4. Gelato: Graph Edit Distance via Autoregressive Neural Combinatorial OptimizationPaolo Pellizzoni, Till Hendrik Schulz, Karsten M. BorgwardtICLR 2026

Builds on16

  1. Open Graph Benchmark: Datasets for Machine Learning on GraphsWeihua Hu, Matthias Fey, Marinka Zitnik, Yuxiao Dong et al.NeurIPS 2020 · 3,935 citations
  2. Can Graph Neural Networks Count Substructures?Zhengdao Chen, Lei Chen, Soledad Villar, Joan BrunaNeurIPS 2020 · 392 citations
  3. What Can Neural Networks Reason About?Keyulu Xu, Jingling Li, Mozhi Zhang, Simon S. Du et al.ICLR 2020 · 281 citations
  4. Equivariant Subgraph Aggregation NetworksBeatrice Bevilacqua, Fabrizio Frasca, Derek Lim, Balasubramaniam Srinivasan et al.ICLR 2022 · 217 citations
  5. Understanding and Extending Subgraph GNNs by Rethinking Their SymmetriesFabrizio Frasca, Beatrice Bevilacqua, Michael M. Bronstein, Haggai MaronNeurIPS 2022 · 168 citations

Related papers

  1. Learning to Count Isomorphisms with Graph Neural NetworksXingtong Yu, Zemin Liu, Yuan Fang, Xinming ZhangAAAI 2023 · 24 citations
  2. Graph Convolutional Networks with Dual Message Passing for Subgraph Isomorphism Counting and MatchingXin Liu, Yangqiu SongAAAI 2022 · 37 citations
  3. Distance-Restricted Folklore Weisfeiler-Leman GNNs with Provable Cycle Counting PowerJunru Zhou, Jiarui Feng, Xiyuan Wang, Muhan ZhangNeurIPS 2023 · 15 citations
  4. Homomorphism Counts for Graph Neural Networks: All About That BasisEmily Jin, Michael M. Bronstein, Ismail Ilkan Ceylan, Matthias LanzingerICML 2024 · 23 citations
  5. Counting Graph Substructures with Graph Neural NetworksCharilaos I. Kanatsoulis, Alejandro RibeiroICLR 2024 · 17 citations
Dusk over the sea between two cliffs drawn in fine vertical lines