Abstract
Graph similarity computation is one of the core operations in many graph-based applications, such as graph similarity search, graph database analysis, graph clustering, etc. Since computing the exact distance/similarity between two graphs is typically NP-hard, a series of approximate methods have been proposed with a trade-off between accuracy and speed. Recently, several data-driven approaches based on neural networks have been proposed, most of which model the graph-graph similarity as the inner product of their graph-level representations, with different techniques proposed for generating one embedding per graph. However, using one fixed-dimensional embedding per graph may fail to fully capture graphs in varying sizes and link structures, a limitation that is especially problematic for the task of graph similarity computation, where the goal is to find the fine-grained difference between two graphs. In this paper, we address the problem of graph similarity computation from another perspective, by directly matching two sets of node embeddings without the need to use fixed-dimensional vectors to represent whole graphs for their similarity computation. The model, GraphSim, achieves the state-of-the-art performance on four real-world graph datasets under six out of eight settings, compared to existing popular methods for approximate Graph Edit Distance (GED) and Maximum Common Subgraph (MCS) computation.
Introduction
Computing the similarity between two graphs is a fundamental operation in domains ranging from drug discovery to social network analysis. However, the gold-standard metrics for this task—Graph Edit Distance (GED) and Maximum Common Subgraph (MCS)—are NP-hard to compute exactly. While recent neural network approaches have attempted to speed up these computations, most rely on a "bottleneck" architecture that compresses an entire graph into a single fixed-length vector. This approach often fails to capture fine-grained structural differences, particularly when graphs vary in size or contain critical local variations.
We propose GraphSim, which moves away from the "one vector per graph" paradigm. Instead, it treats pairwise node similarities as a multi-scale "image" and utilizes Convolutional Neural Networks (CNNs) to recognize structural patterns, achieving state-of-the-art accuracy and efficiency.
The GraphSim Architecture
GraphSim treats graph matching as a multi-scale pattern recognition task through three main stages:
- Multi-Scale Neighbor Aggregation: The model uses several Graph Convolutional Network (GCN) layers. Each layer produces node embeddings that capture information from increasingly larger neighborhoods (1-hop, 2-hop, etc.).
- Similarity Matrix Generation: For every pair of nodes between two graphs, the model computes an inner product of their embeddings. This is done for each GCN layer, resulting in multiple "similarity matrices." To ensure consistency, nodes are sorted using BFS (Breadth-First Search) ordering, which preserves spatial locality—ensuring that nodes close in the graph remain close in the matrix.
- CNN-Based Matching: These matrices are treated as channels in an image. Just as a CNN detects edges in a photo, GraphSim’s CNN layers detect "similarity patterns," such as diagonal lines representing isomorphic subgraphs.
To handle graphs of different sizes, the model employs Max Padding and Matrix Resizing (via bilinear interpolation) to ensure the input to the CNN is always of a fixed dimension.
Experimental Results
The authors evaluated GraphSim on five diverse real-world datasets, including chemical compounds (AIDS, PTC), program dependence graphs (LINUX), and social networks (IMDB, REDDIT12K).
Accuracy and Efficiency
GraphSim achieved the lowest Mean Squared Error (MSE) and best ranking performance (Spearman’s $ ho$) in six out of eight experimental settings, outperforming popular models like SimGNN and GMN. Beyond accuracy, GraphSim provides a fast approximation in quadratic time ($O(N^2)$). As shown in the efficiency analysis, it is significantly faster than traditional algorithmic heuristics like the Hungarian or VJ methods on larger datasets and remains competitive with other neural approaches while offering better precision.
Conclusion
By transforming graph matching into a continuous computer vision problem, GraphSim effectively captures both local and global structural similarities. While BFS ordering is a heuristic and the $O(N^2)$ cost remains a factor for massive graphs, the model's ability to visualize similarity through "images" provides a level of interpretability previously missing in neural graph matching. Future work will focus on more stable node ordering and extending the model to generate explicit edit sequences.
Summary updated