Abstract
Graph Similarity Learning (GSL) is a foundational task for applications ranging from drug discovery to malware analysis. While real-world graphs are predominantly heterogeneous—containing diverse types of nodes and edges—most existing GSL methods treat them as homogeneous, leading to significant loss of semantic information. This paper introduces HeGMN, a novel Heterogeneous Graph Matching Network framework. By utilizing a new heterogeneous encoder (HGIN) and a "type-aligned" matching mechanism, HeGMN explicitly leverages node and edge semantics to improve both accuracy and computational efficiency. Experimental results demonstrate that HeGMN reduces prediction error by up to 43.75% compared to state-of-the-art baselines.
The Challenge of Heterogeneity in Graph Similarity
Graph Similarity Learning (GSL) aims to measure the structural and semantic correspondence between two graphs. A standard metric for this is the Graph Edit Distance (GED), which represents the minimum number of edit operations (insertions, deletions, or substitutions) required to transform one graph into another. Because calculating exact GED is NP-hard, researchers typically use Graph Neural Networks (GNNs) to approximate it.
However, most current GSL models assume graphs are homogeneous. This assumption fails in domains like chemistry or citation networks where node types carry essential meaning. For example, in a molecular graph, a carbon atom is fundamentally different from a hydrogen atom. If a model ignores these types, it may predict that two structurally similar but chemically distinct molecules are identical. HeGMN addresses this by incorporating heterogeneous semantics directly into the matching process.
Methodology: The HeGMN Framework
HeGMN is an end-to-end framework featuring several innovations designed to respect the diverse semantics of heterogeneous graphs.
Heterogeneous Graph Edit Distance (HGED)
The authors propose a new metric, HGED, which ensures semantic consistency during graph transformation. Unlike standard GED, HGED requires a strict two-step process for changing an element's type (deleting the old type and adding the new) to maintain the integrity of the graph's heterogeneous nature.
HGIN Encoder and Type-Aligned Matching
To encode these graphs, the authors developed HGIN (Heterogeneous Graph Isomorphism Network). HGIN extends the standard GIN by using a relational attention mechanism to aggregate information differently based on edge types. To ensure scalability, the model employs matrix decomposition to handle the increased complexity of multiple relations.
The core innovation of HeGMN is its Type-Aligned Matching strategy:
- Graph-Level Matching: Node embeddings are pooled by type. The model then matches these type-specific clusters across the two graphs and fuses them using an attention mechanism.
- Node-Level Matching (The "Type Mask"): Standard node-level matching is computationally expensive ($O(N^2)$). HeGMN applies a "type mask" that restricts cross-graph interactions to nodes of the same type. This not only reduces semantic noise but also drastically improves execution speed.
Key Results and Insights
HeGMN was evaluated against 12 baselines across four heterogeneous datasets: ACM1000, DBLP700, IMDB1200, and MUTAG. The framework consistently achieved state-of-the-art performance:
- Accuracy Gains: On the ACM1000 dataset, HeGMN reduced the Mean Squared Error (MSE) by 43.75% compared to the next best baseline. On IMDB1200, it showed an 18.73% improvement.
- Ranking Performance: The model achieved the highest scores in ranking correlation metrics (Spearman’s $\rho$ and Kendall’s $\tau$), making it highly effective for similarity-based retrieval.
- Efficiency: Despite performing complex node-level matching, HeGMN recorded the fastest running time among all node-matching baselines, validating the efficiency of the type-masking strategy.
Ablation studies confirmed that "cross-type matching"—allowing nodes of different types to interact—actively harms performance. Forcing the model to align identical types eliminates noise and allows the network to focus on relevant structural similarities.
Conclusion
HeGMN demonstrates that explicitly modeling heterogeneity is essential for accurate graph similarity learning. By combining a theoretically sound encoder (HGIN) with a type-aligned matching mechanism, the framework achieves significant gains in both precision and speed. Future work will explore deeper integration of edge semantics and dynamic mechanisms to learn the relative importance of different node types.
Summary updated