SEGMN: A structure-enhanced graph matching network for graph similarity learning

Wenjun Wang, Jiacheng Lu, Kejia Chen, Zheng Liu, Shilong Sang

TL;DR

This paper introduces SEGMN, a novel framework for learning graph similarity by explicitly incorporating structural information into both node representations and the cross-graph matching process. By leveraging dual embeddings that consider edge information and a structure perception module that analyzes the assignment graph, SEGMN significantly outperforms existing methods on graph edit distance prediction tasks.

What Problem Does This Paper Address?

Graph Similarity Computation (GSC) is a crucial task with applications ranging from molecular analysis to code similarity detection. Traditional methods like Graph Edit Distance (GED) and Maximum Common Subgraph (MCS) are computationally expensive. While Graph Neural Networks (GNNs) have advanced GSC by learning node embeddings, existing GNN-based approaches often struggle with two key issues:

  1. Representation Limitation: They primarily focus on intra-graph structures, neglecting the crucial role of edges in capturing a node's context and the overall graph structure. This leads to incomplete node representations.
  2. Matching Inadequacy: Current cross-graph matching strategies operate on node embeddings that are confined to their respective graphs. This lack of "inter-graph structure perception" can result in inaccurate similarity scores, as it doesn't consider how nodes and their relationships align across the two graphs.

The paper aims to bridge this gap by developing a method that enhances both the representation of individual nodes and the matching process by explicitly considering the structural relationships between nodes and edges within and across graphs.

Methods

SEGMN is built upon four key modules:

  1. Dual Embedding Learning: This module enhances node representations by incorporating information from adjacent edges. It first transforms the node graph into its line graph, where nodes represent edges. An edge-enhanced GCN is applied to this line graph to learn edge embeddings. These edge embeddings are then aggregated and concatenated with the standard node embeddings (learned via a GCN on the original node graph) to create "dual embeddings." This dual representation provides nodes with a richer, structure-aware context.
  2. Cross-Graph Interaction: This module computes an initial similarity matrix between pairs of nodes from the two graphs. It uses a node-graph attention mechanism, where dual embeddings from one graph are queried against the dual embeddings of the other. This results in two similarity matrices, capturing similarity from both perspectives.
  3. Structure Perception Matching: This is the core novel contribution. It leverages an "assignment graph," which represents potential node pairings between the two input graphs. By performing a GCN-based convolution on this assignment graph, where node features are initialized with the similarity scores from the cross-graph interaction module, this module explicitly models and aggregates structural relationships between node pairs. This process refines the initial similarity matrix, making it more sensitive to structural similarities and differences.
  4. Similarity Matrix Learning: The refined similarity matrices are then processed to predict the final graph similarity score. This involves a self-attention mechanism applied to the flattened similarity matrices, followed by a CNN with cross-shaped filters to capture local structural patterns. Finally, an MLP outputs the predicted graph similarity score.

Datasets

The paper evaluates SEGMN on three benchmark real-world datasets:

  • AIDS700: A dataset of molecular graphs.
  • LINUX: A dataset of code graphs.
  • IMDB-small and IMDB-large: Datasets of social network graphs, split to evaluate performance on graphs of different sizes.

The paper does not introduce new datasets but uses established ones for evaluation.

Key Insights and Ideas

  • Edges Matter for Node Representation: Simply using node embeddings from standard GNNs is insufficient. Incorporating edge information into node representations (dual embeddings) significantly improves the ability to capture structural nuances.
  • Cross-Graph Structure is Key for Matching: Directly comparing node embeddings from separate graphs misses critical inter-graph structural context. The "structure perception matching" module, by operating on an assignment graph, explicitly models these cross-graph structural relationships, leading to more accurate similarity scores.
  • Modularity for Improvement: The structure perception matching module is designed to be plug-and-play. It can be integrated with existing GSC methods that produce similarity matrices, offering a straightforward way to enhance their performance.
  • Unlabeled Graphs Benefit More: The experiments suggest that the structure perception module provides greater improvements on unlabeled datasets (like LINUX) where structural similarity is the primary determinant of graph edit distance.

Key Results

SEGMN consistently outperforms state-of-the-art GSC methods across all tested datasets and metrics, particularly in terms of Mean Square Error (MSE). For example, on the LINUX dataset, SEGMN achieves an MSE of 0.094, significantly lower than other methods. The paper also demonstrates that the dual embedding module and the structure perception matching module individually contribute to performance gains, and their combination in SEGMN yields the best results. An ablation study shows that adding the structure perception module to GraphSim can improve its performance by up to 25%.

Limitations and Future Work

  • Computational Cost: While SEGMN improves accuracy, the paper doesn't explicitly detail its computational complexity compared to baselines, which is a common trade-off with more complex models.
  • Generalizability of SPM: The paper shows the SPM module is portable and improves GraphSim. Future work could explore its integration with a wider range of GSC methods and investigate its effectiveness on different types of graph data.
  • Structure Perception Depth: The paper demonstrates how SPM corrects similarity scores based on structural differences. Further research could delve deeper into quantifying and visualizing how the SPM module perceives and differentiates complex structural variations.

Summary updated

BibTeX
@article{wang2024segmn,
  author = {Wenjun Wang and Jiacheng Lu and Kejia Chen and Zheng Liu and Shilong Sang},
  title = {{SEGMN: A structure-enhanced graph matching network for graph similarity learning}},
  journal = {Pattern Recognition},
  year = {2024},
}
Figure