Manuscript Offprint

arXiv:2611.09805

Scaling Graph Similarity Learning with Graph Neural Networks

Ahmet Tüzen, Helge Langseth, Kjetil Nørvåg

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Graph similarity computation is an important task in graph mining with many real-world applications, such as chemical compound analysis, program dependence comparison, and social network analysis. The problem is computationally challenging: Graph Edit Distance (GED) and Maximum Common Subgraph (MCS), which quantify the distance between graphs and identify their largest shared subgraph, respectively, are NP-hard to compute exactly. To address these computational challenges, Graph Neural Networks (GNNs) have been applied to this problem. However, existing GNN-based approaches have primarily focused on small-scale graph datasets, while scalability to larger scales remains under-explored. In this work, we propose FiLSim, a scalable GNN-based framework, and investigate whether a simplified GNN pipeline can maintain competitive performance on standard benchmarks while scaling to large graphs. We additionally propose a sequential graph-editing strategy to construct large-scale graph datasets with reliable GED labels to evaluate scalability. The proposed framework is evaluated on four benchmark datasets and four newly created large-scale datasets, demonstrating its effectiveness and scalability. FiLSim remains accurate on graphs with more than 150,000 nodes, where the baseline methods run out of memory or fail to learn, and scores all test pairs within seconds on a single GPU.

Keywords: graph similarity learning, graph neural networks, large-scale graphs, graph edit distance, maximum common subgraph

1 Introduction

Graphs represent entities and the relations between them, and many real-world data, such as social and biological networks, are naturally described in this form. Graph structures are therefore widely adopted across many areas, such as social networks and biological networks, and are a common data structure in machine learning and data mining.

Graph matching is the problem of finding an optimal node-to-node correspondence between two graphs. In many real-world applications, requiring exact matching is impractical, and approximate formulations that measure graph similarity are more appropriate. This has motivated research on graph similarity learning, which aims to quantify the degree of similarity between graphs as a continuous score rather than finding correspondences. Both graph matching and graph similarity computation are computationally challenging. Graph Edit Distance (GED) (Bunke & Allermann, 1983) quantifies the similarity between two graphs by the cost of edit operations (e.g., node and edge insertions and deletions) required to transform one graph into the other, with lower values indicating higher similarity. Maximum Common Subgraph (MCS) (Bunke & Shearer, 1998) identifies the largest isomorphic subgraph shared by two graphs. Computing these metrics is NP-hard and quickly becomes intractable as the graph size increases (P. Yang et al., 2024). This computational barrier limits their applicability in real-world settings where graphs may contain hundreds or thousands of nodes. A toy example of graph matching and GED is given in Appendix A.

Graph Neural Networks (GNNs) (Gori, Monfardini, & Scarselli, 2005; Scarselli, Gori, Tsoi, Hagenbuchner, & Monfardini, 2009) are widely used for learning on graph-structured data. GNNs iteratively aggregate information from neighboring nodes, which allows them to capture both local neighborhood properties and broader graph patterns (Zhou et al., 2020). GNNs have demonstrated strong performance across a wide range of graph-level downstream tasks, including node classification, graph classification, anomaly detection, and graph generation. Recent studies have adopted GNN architectures for graph matching and graph similarity learning (Ma, Ahmed, Willke, & Yu, 2021). However, existing GNN-based graph similarity methods are limited in scale (Jiang, Ning, & Dong, 2023). Most approaches are designed for and evaluated on datasets containing small graphs. Many rely on operations such as node-level cross-graph attention or pairwise node comparisons, which typically scale quadratically with graph size. In addition, the lack of large-scale benchmark datasets has prevented a systematic study of whether these methods can scale to the graph sizes encountered in domains such as social network analysis.

To address these challenges, we propose FiLSim (FiLM-conditioned Large-graph Similarity), a scalable GNN-based framework for graph similarity learning. Our framework combines a shared GNN-based encoder with simple feature augmentation, graph-level pooling over the outputs of all encoder layers, and a prediction module based on Feature-wise Linear Modulation (FiLM) (Perez, Strub, de Vries, Dumoulin, & Courville, 2018) that operates on graph-level embeddings. This design allows each graph to be encoded independently and avoids expensive node-level alignment. We also introduce a systematic data-generation approach that produces large-scale synthetic datasets from real graphs, which allows us to train and evaluate FiLSim at previously unexplored scales. We consider static, undirected graphs whose nodes are either unlabeled or carry discrete labels. We use GED with a unit cost for every edit operation. The main contributions of this work are summarized as follows:

  • Scalable Pipeline: We demonstrate that a simplified GNN-based framework replacing node-level cross-graph alignment with efficient graph-level pooling can compute graph similarity at scales of more than 150,000 nodes without sacrificing performance on small benchmarks.

  • Large-Scale Graph Datasets: We construct large-scale synthetic graph datasets from real graphs with more than 150,000 nodes in the main experiments and more than 300,000 nodes in the extended experiments, i.e., graphs more than 1000× larger than those in existing benchmark datasets. We provide a sequential approach to generating these datasets, in which each label is an upper bound on the GED by construction, and all pairs among the generated graphs are labeled.

  • Comprehensive Evaluation: Through experiments on all datasets, we demonstrate that our method achieves the lowest error on all benchmark datasets and is the only method that remains accurate on all large-scale datasets, whereas each baseline runs out of memory or fails to learn on at least one of them.

  • Cost and Design Analysis: We measure the cost of every stage of training and inference and ablate each component of the model, showing that the encoding cost grows linearly with the graph size and quantifying the contribution of each design choice.

References (66)