Introduction
Measuring how similar two graphs are—known as Graph Similarity Computation (GSC)—is a fundamental task in fields ranging from drug discovery and malware detection to social network analysis. However, calculating exact metrics like Graph Edit Distance (GED) is NP-hard, making it computationally prohibitive for large-scale databases.
To address this, researchers have increasingly turned to deep learning approaches using Graph Neural Networks (GNNs) to approximate these scores. This paper introduces a novel "Slow Learning, Fast Inference" framework for GSC. By training a high-accuracy "Teacher" model with complex early-fusion interactions and distilling its knowledge into a Siamese "Student" model, the authors achieve state-of-the-art accuracy while enabling massive speedups (over 10x–100x) through offline embedding pre-computation.
The Challenge of Graph Similarity
Current GNN-based methods generally fall into two camps, each with a distinct trade-off:
- Early-Fusion (Accurate but Slow): These models compare graphs layer-by-layer using "cross-graph" attention. While highly accurate, they are slow because every pair of graphs must be processed together through the entire network at query time.
- Late-Fusion/Siamese (Fast but Less Accurate): These models compute an individual embedding for each graph independently. This allows systems to pre-calculate and store "fingerprints" for a whole database, making search nearly instantaneous. Unfortunately, they often miss subtle structural differences that early-fusion models catch.
The authors aim to bridge this gap: capturing the high accuracy of early-fusion models while maintaining the blazing-fast inference speed of Siamese models.
Proposed Framework: Slow Learning, Fast Inference
The authors propose a two-stage framework to achieve their goal:
1. The Teacher Model (EGSC-T)
This is the "Slow Learning" component. It uses a Graph Isomorphism Network (GIN) as a backbone to extract powerful features. To capture dense interactions between the two input graphs at multiple levels, it employs a novel Embedding Fusion Network (EFN) with co-attention. The teacher doesn't just look at the final output; it fuses features from every layer of the GNN. This "multi-scale" view allows the model to catch both local node-level differences and global structural shifts.
2. Embedding Decomposition and The Student Model (EGSC-S)
To transfer knowledge to a Siamese student, the authors had to solve a tricky problem: how do you distill a "joint" representation (where two graphs are mixed) into "individual" representations?
They proposed a linear decomposition strategy, creating pseudo-individual embeddings by subtracting duplicate graph embeddings from the joint ones. This was a significant technical breakthrough, as standard Knowledge Distillation (KD) fails when trying to align a joint embedding with individual ones. By decomposing the teacher's joint features, they provided a clear target for the student to follow.
The "Fast Inference" component is the Student Model (EGSC-S). It is a Siamese network that learns to mimic the teacher’s pseudo-individual embeddings using KD. Because the student processes graphs independently, its embeddings can be collected offline. This transforms the GSC problem from a heavy GNN computation into a simple vector comparison at runtime, moving GSC from an academic curiosity to an industrial-scale solution.
Experimental Results
The model was evaluated on four standard GSC benchmarks: AIDS (700 chemical compound graphs), LINUX (1,000 program dependence graphs), IMDB (1,500 ego-networks of movie actors), and ALKANE (120 acyclic chemical compound graphs).
- Accuracy: The Teacher model (EGSC-T) outperformed previous state-of-the-art methods (like SimGNN and GraphSim) across almost all metrics, including MSE and Spearman’s $\rho$.
- Speed: The Student model (EGSC-S) maintained nearly the same accuracy as the teacher but achieved massive speedups. On the AIDS dataset, the student model was over 75x faster than the competitive SimGNN when using offline embeddings (0.148s vs 11.139s for the test set).
- Robustness: Ablation studies showed that using GIN as a backbone and the specific KD loss (incorporating both first and second-order distances) were critical to the performance gains.
Limitations and Future Work
While highly effective, the framework has a few limitations. The embedding decomposition relies on the assumption that joint embeddings can be represented as a linear combination of individual ones. While this worked well in practice, more complex non-linear decomposition methods could be explored in the future.
Additionally, the paper focuses primarily on Graph Edit Distance (GED). While the authors suggest the method is generalizable, future work could explicitly test it on other metrics like Maximum Common Subgraph (MCS). Finally, testing the scalability of the teacher's co-attention on much larger graphs remains an open challenge, as the current benchmark datasets consist of relatively small graphs.
Summary updated