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

Size-Invariant Graph Representations for Graph Classification Extrapolations

Beatrice Bevilacqua, Yangze Zhou, Bruno Ribeiro

TL;DR

This paper introduces a causal framework to tackle out-of-distribution (OOD) graph classification, specifically focusing on "size extrapolation"—training on small graphs and testing on much larger ones. By leveraging the stability of subgraph densities (graphons), the authors develop a representation method that remains invariant to changes in graph size and shifting vertex attributes, significantly outperforming standard Graph Neural Networks (GNNs) in non-i.i.d. settings.

What Problem Does This Paper Address?

Most graph representation learning methods rely on a fundamental assumption: that training and test data come from the same distribution (i.i.d.). In the real world, this is rarely true. A model trained to classify small molecules might fail when presented with larger ones, or a model trained on social networks from one region might fail on another due to different attribute distributions.

The authors focus on Out-of-Distribution (OOD) extrapolation. Specifically, they address two challenges:

  1. Size Extrapolation: When the number of vertices in test graphs is significantly different from those in training.
  2. Attribute Shift: When the relationship between vertex features (like "color" or "type") and the target label changes between environments.

Standard GNNs are prone to "shortcut learning"—they might accidentally learn that "small graphs are Class A" simply because the training set was biased that way. When the test set contains large Class A graphs, the model fails.

Methods

The researchers propose a Structural Causal Model (SCM) inspired by Graphon theory. A graphon is essentially the limit of a sequence of dense graphs; it describes the underlying "recipe" for generating a graph regardless of its final size.

Structural Causal Model (SCM) for graph classification under distribution shift.

Key components of their approach include:

  • Induced Homomorphism Densities: Instead of looking at the whole graph at once, the model counts how often specific small subgraphs (like triangles or paths) appear. Theoretically, these densities are "size-invariant" signatures of the underlying graphon.
  • E-Invariant Representations: They define a representation $\Gamma$ as "environment-invariant" if it produces the same output for graphs generated from the same graphon, regardless of the environment (size or attribute noise).
  • Subgraph-based GNNs ($\Gamma_{GIN}, \Gamma_{RPGIN}$): They use GNNs to learn representations of small $k$-sized subgraphs and then weight these by their observed densities in the larger graph.
  • Attribute Regularization: To handle shifting vertex attributes, they introduce a penalty term that forces the GNN to ignore attribute differences that don't change the underlying structural topology. This prevents the model from relying on "spurious" correlations between attributes and labels.

Datasets

The authors evaluated their approach on both synthetic and real-world benchmarks:

  • Synthetic Erdos-Renyi: Classifying graphs based on their edge probability ($p$). Training on size 80, testing on size 140.
  • Synthetic SBM (Stochastic Block Model): A task involving both size shifts and flipped vertex attribute distributions (e.g., "red" nodes become "blue" nodes in the test set).
  • Schizophrenia Task: Real-world fMRI brain graphs. Training on graphs with 264 vertices and testing on a control group with ~40% fewer vertices.
  • TUDataset (NCI1, NCI109, PROTEINS, DD): Standard molecular and protein datasets, re-split to create OOD size challenges where test graphs are significantly larger than training graphs.

Key Insights and Ideas

  • Size as a Collider: In their causal DAG, the environment (which determines size) and the underlying Graphon both influence the final graph. This makes the observed graph a "collider," meaning standard learning can create a false dependency between size and the target label.
  • The Stability of Subgraphs: The "aha moment" is the mathematical proof showing that as a graph grows, the density of its subgraphs converges to a constant value determined by the graphon. This provides a rock-solid, size-invariant feature set.
  • Failure of IRM: The paper shows that Invariant Risk Minimization (IRM)—a popular OOD technique—often fails for graphs because it struggles with non-linear shifts and requires multiple training environments, whereas the proposed method can extrapolate even from a single training environment.

Key Results

The proposed invariant representations consistently outperformed state-of-the-art GNNs (like GIN, GCN, and PNA) in OOD scenarios:

Accuracy comparison on Schizophrenia and Erdos-Renyi tasks under size shift.
  • Erdos-Renyi: While standard GNNs dropped to ~60-65% accuracy when the graph size increased, the proposed $\Gamma_{GIN}$ maintained 100% accuracy.
  • SBM with Attribute Shift: In the most difficult scenario (shifting both size and attributes), standard GNNs fell to ~50-65% accuracy, while the authors' regularized $\Gamma_{GIN}$ achieved 95-98% accuracy.
  • Schizophrenia Task: Their method achieved 71-72% accuracy, significantly higher than the 36-61% range seen in standard GNN baselines.
  • Real-World OOD: On the DD (protein) dataset, their method achieved a Matthews Correlation Coefficient (MCC) of 0.28, while standard GIN only managed 0.25, and some baselines dropped to near-random performance.

Limitations and Future Work

  • Computational Complexity: Counting induced subgraphs (subgraph isomorphism) is notoriously expensive. While the authors use efficient algorithms, the approach is currently limited to small subgraph sizes (typically $k \le 5$).
  • Dense Graph Assumption: Graphon theory is primarily designed for dense graphs. Extending this to very sparse real-world graphs (like massive social networks) remains a theoretical challenge.
  • Causal Assumptions: The method assumes that the relationship $P(Y|G)$ (the "mechanism") remains invariant. If the very nature of the classification task changes between training and test, no amount of representation invariance will help.

Future work could involve scaling these methods to larger subgraphs or exploring "graphon-pooling" layers within standard GNN architectures to bake in size-invariance more natively.

Summary updated

BibTeX
@inproceedings{bevilacqua2021size,
  author = {Beatrice Bevilacqua and Yangze Zhou and Bruno Ribeiro},
  title = {{Size-Invariant Graph Representations for Graph Classification Extrapolations}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=CdnDCbJv6UO},
}
Figure