SamGoG: A Sampling-Based Graph-of-Graphs Framework for Imbalanced Graph Classification

Shangyou Wang, Zezhong Ding, Xike XiearXiv 2025 · DOI

Introduction

Graph Neural Networks (GNNs) have revolutionized the field of graph classification. However, their performance often degrades when faced with two common real-world data challenges: class imbalance and graph size imbalance. Class imbalance, where certain categories have significantly more training examples than others, often biases models toward majority classes. Graph size imbalance occurs when input graphs vary significantly in their number of nodes, making it difficult for models to generalize from large "head" graphs to small "tail" graphs.

Impact of class and graph size imbalance on dataset distribution and model accuracy.

Existing solutions typically tackle only one of these issues or rely on "Graph-of-Graphs" (GoG) paradigms that use computationally expensive graph kernels (like Weisfeiler-Lehman) to determine inter-graph similarity. These kernels often prioritize structural features over semantic ones and create static, one-shot graph structures that cannot adapt during the training process.

The SamGoG Framework

To address these limitations, we propose SamGoG, a sampling-based framework that treats each individual input graph as a node in a higher-level meta-graph. SamGoG achieves state-of-the-art accuracy with significantly lower computational overhead than traditional kernel-based methods by employing a learnable similarity metric and an adaptive sampling strategy.

The SamGoG framework architecture, illustrating the transition from individual graphs to a sampled Graph-of-Graphs (GoG).

Core Innovations

  1. Learnable Pairwise Similarity: Instead of relying on static kernels, SamGoG uses a multi-layer perceptron (MLP) to compute similarity between graph representations. This approach accounts for both structural information (via GNN encoders) and label certainty, making the similarity metric "semantic-aware."
  2. Adaptive Node Degree Allocation: Rather than giving every node in the GoG a fixed number of neighbors, SamGoG uses three specific rules to distribute an "edge budget" ($\Delta$):
  3. Rule 1 (Label Priority): Labeled nodes receive higher degrees because they provide more reliable supervision.
  4. Rule 2 (Class Imbalance): Majority class nodes are assigned higher degrees to better embed and support minority class representations.
  5. Rule 3 (Size Adaptation): Unlabeled nodes are given degrees based on how well their size aligns with the training size distribution, facilitating better knowledge transfer across different graph scales.
  6. Dynamic Parallel Sampling: To reduce inductive bias and improve efficiency, the model samples multiple sub-GoGs during each training epoch. This allows the inter-graph relationships to evolve dynamically as the GNN encoders improve.

Key Insights and Results

A central theoretical contribution of SamGoG is the formulation of GoG construction as a constrained homophily maximization problem. The authors demonstrate that the overall homophily of the meta-graph—the tendency of connected nodes to share the same label—can be improved by strategically allocating more neighbors to nodes that have a higher probability of connecting to the correct class.

Experimental Performance

The authors evaluated SamGoG using the IGL-Bench, including TUDatasets (PTC-MR, D&D, IMDB-BINARY, REDDIT-BINARY) and the large-scale ogbg-molhiv molecular property prediction dataset.

  • Accuracy Gains: SamGoG achieved an average accuracy improvement of 5.07% across class imbalance experiments and 4.13% across size imbalance experiments. In the best-case scenario, it improved accuracy by as much as 15.66%.
  • Efficiency: By replacing graph kernels with parallelizable matrix operations ($S = PP^T$), the framework achieves up to 6.7× training acceleration over baselines. On the ogbg-molhiv dataset, SamGoG completed preprocessing in just 0.03 seconds, avoiding the "Out of Memory" (OOM) errors that plagued other GoG methods.

Conclusion

SamGoG represents a significant step forward in imbalanced graph learning. By treating graph classification as a node classification problem on a meta-graph with adaptive degrees, it effectively bridges the gap between large and small graphs while remaining robust to class skews. Future work may extend this paradigm to tasks such as graph regression or link prediction, further exploring the potential of high-homophily meta-structures.

Summary updated

BibTeX
@misc{wang2025samgog,
  author = {Shangyou Wang and Zezhong Ding and Xike Xie},
  title = {{SamGoG: A Sampling-Based Graph-of-Graphs Framework for Imbalanced Graph Classification}},
  year = {2025},
  eprint = {2507.13741},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.13741},
}
Figure