Learning-based Efficient Graph Similarity Computation via Multi-Scale Convolutional Set Matching

Yunsheng Bai, Hao Ding, Yizhou Sun, Wei Wang · DOI

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: Beyond the Embedding Bottleneck

Determining how similar two graphs are is a fundamental task in everything from drug discovery (comparing molecules) to cybersecurity (detecting malware). Traditionally, we use metrics like Graph Edit Distance (GED)—the number of operations needed to transform one graph into another—or Maximum Common Subgraph (MCS).

The challenge lies in the fact that computing these exactly is NP-hard. While recent deep learning approaches have tried to speed this up, most rely on "graph-level embeddings," squashing an entire complex graph into a single fixed-length vector. This "bottleneck" often loses the fine-grained structural details necessary to spot subtle differences between two nearly identical graphs. The authors of GraphSim argue that to truly understand similarity, we need to look at how individual nodes relate to one another across different scales of the graph.

The GraphSim Architecture

GraphSim moves away from the "one vector per graph" paradigm by directly matching sets of node embeddings. Its pipeline consists of four main stages:

The GraphSim architecture: Multi-scale neighbor aggregation, similarity matrix generation, and CNN-based matching.
  1. Multi-Scale Neighbor Aggregation: Using Graph Convolutional Networks (GCNs), the model generates node embeddings. By taking the output of every GCN layer, the model captures information at different scales—from a node’s immediate neighbors to its broader structural role.
  2. BFS Node Ordering: To treat similarity as a pattern recognition problem, nodes need a consistent order. The authors use a Breadth-First Search (BFS) starting from high-degree nodes. This ensures that nodes close to each other in the graph are placed near each other in the similarity matrix, preserving "spatial locality."
  3. Similarity Matrix Generation: For every pair of nodes between Graph A and Graph B, the model computes an inner product. This results in a "similarity image" for each scale. If two subgraphs are identical, this "image" will show a distinct diagonal pattern.
  4. CNN-Based Matching: These similarity matrices are fed into a CNN. Just as a CNN recognizes edges or shapes in a photo, here it recognizes matching structural patterns between the two graphs.

Key Insights: Similarity as Vision

The most striking innovation is framing graph matching as an image recognition task. When nodes are ordered via BFS, isomorphic (identical) subgraphs manifest as bright diagonal lines in the similarity matrix. CNNs are naturally optimized to detect these types of patterns. Furthermore, the multi-scale approach ensures that different types of errors are caught: a single atom change might be obvious at a local scale, while large structural shifts are only visible at higher scales.

Performance and Results

The model was evaluated on several diverse real-world datasets, including chemical compounds (AIDS, PTC), program structures (LINUX), and social networks (IMDB, REDDIT12K).

Computation time comparison across different datasets and methods.
  • State-of-the-Art Accuracy: GraphSim outperformed existing neural methods (like SimGNN and GMN) and traditional approximate algorithms in 6 out of 8 experimental settings for GED and MCS.
  • Efficiency: While exact solvers fail on graphs with more than 16 nodes, GraphSim provides high-quality approximations in polynomial time ($O(N^2)$). As shown in the timing results, GraphSim is significantly faster than exact solvers like A* and competitive with other learning-based methods.
  • Interpretability: Because the model produces similarity "images," researchers can visualize which parts of two graphs the model thinks are matching, providing a level of transparency often missing in GNNs.

Conclusion

GraphSim demonstrates that matching sets of node embeddings across multiple scales is a superior approach to compressing graphs into single vectors for similarity tasks. By leveraging the pattern-recognition strengths of CNNs on similarity "images," it achieves a new state-of-the-art in both accuracy and efficiency. Future work may explore hierarchical graph pooling to handle even larger graphs and extending the framework to explicit network alignment.

Summary updated

BibTeX
@inproceedings{bai2020learning,
  author = {Yunsheng Bai and Hao Ding and Yizhou Sun and Wei Wang},
  title = {{Learning-based Efficient Graph Similarity Computation via Multi-Scale Convolutional Set Matching}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2020},
  doi = {10.1609/aaai.v34i04.5720},
}
Figure