Abstract
Graph similarity computation is a cornerstone of data science, yet traditional exact methods like Graph Edit Distance (GED) are NP-hard. While deep learning approaches offer significant speedups, they often function as "black boxes," providing similarity scores without interpretable node-level alignments. This paper introduces GNA (Neural Node Alignment), a framework that utilizes a differentiable Gumbel-Sinkhorn module to achieve state-of-the-art accuracy in GED approximation. By enforcing hard one-to-one node alignments, GNA provides interpretable results and outperforms existing models on diverse real-world datasets, learning optimal mappings without requiring node-level ground truth labels.
Introduction
Comparing two graphs—whether they represent chemical compounds, social networks, or program structures—is a fundamental task in data science. Traditionally, this is performed using Graph Edit Distance (GED) or Maximum Common Subgraphs (MCS). However, calculating these metrics exactly is computationally prohibitive as graphs grow in size, as the underlying quadratic assignment problem is NP-hard.
While neural models have been proposed to accelerate these computations, they typically suffer from two major flaws. First is the "black box" problem: they provide a similarity score but fail to explain the underlying node-level correspondence that justifies the score. Second, existing models often rely on "soft alignment" (probabilistic guesses), whereas practical applications frequently require the strict "hard alignment" provided by classical methods. GNA addresses these challenges by introducing a differentiable mechanism for hard node alignment.
The GNA Framework
The GNA architecture is designed to mimic the logic of classical graph matching while maintaining the efficiency of neural networks. It breaks the problem into three integrated modules.
1. Embedding Module
The process begins by encoding nodes into high-dimensional vectors. GNA utilizes a three-layer Graph Isomorphism Network (GIN). GIN is specifically chosen for its theoretical power, as it is proven to be as discriminative as the Weisfeiler-Lehman (WL) isomorphism test. This ensures that the local neighborhood structure of each node is effectively captured before the alignment phase.
2. Costing and Matching Modules
The core innovation of GNA lies in how it handles the alignment problem. The model relaxes the complex quadratic assignment problem inherent in GED into a linear alignment problem within the node embedding space.
- Gumbel-Sinkhorn Module: To bridge the gap between differentiable training and discrete "hard" alignment, GNA employs a Gumbel-Sinkhorn module. This module applies iterative row and column normalization (the Sinkhorn operator) to a cost matrix, combined with Gumbel noise. This process allows the model to approximate a permutation matrix—representing a strict one-to-one mapping—while remaining end-to-end trainable via gradient descent.
- Virtual Nodes: To compare graphs of different sizes, GNA pads the smaller graph with "virtual nodes." These nodes are initialized with the global graph embedding, allowing the model to explicitly calculate the cost of node additions or deletions, mirroring the edit operations in GED.
3. Prediction Module
The final similarity score is derived by combining the node-level matching matrix with the calculated costs of substitution, addition, and deletion. This ensures the final output is grounded in the structural alignment discovered by the model.
Experimental Evaluation
The performance of GNA was evaluated across three diverse real-world datasets, representing different graph scales and domains.
- AIDS: A collection of 700 antiviral chemical compounds where nodes represent atoms (C, O, N) and edges represent chemical bonds.
- Linux: 1,000 Program Dependence Graphs (PDGs) derived from the Linux kernel, where nodes are function statements.
- IMDB: 1,500 ego-networks of movie actors, where edges represent co-starring roles. This dataset is significantly more complex, with much higher average node and edge counts compared to the others.
Key Results and Insights
GNA demonstrated superior performance against several state-of-the-art (SOTA) baselines, including SimGNN, GOTSim, and GEDGNN.
Accuracy and Retrieval
The model achieved up to a 16% reduction in Mean Squared Error (MSE) for GED approximation. In graph retrieval tasks—where the goal is to find the most similar graphs in a database—GNA showed a 12% improvement in Precision@10 metrics. These results suggest that the structural constraints imposed by the alignment module actually improve the model's predictive power rather than hindering it.
Interpretability and Unsupervised Learning
Unlike previous neural models, GNA provides visual proof of its reasoning. The matching matrix successfully identifies isomorphic subgraphs and correctly identifies nodes that should be "deleted" to transform one graph into another. Remarkably, GNA learns these alignments in an unsupervised manner; it does not require node-level ground truth during training, learning the optimal mapping solely by minimizing the error in the final graph-level similarity score.
Conclusion
GNA represents a significant step forward in making graph neural networks both more accurate and more interpretable. By integrating the Gumbel-Sinkhorn module, the framework successfully approximates the discrete logic of Graph Edit Distance within a differentiable deep learning pipeline. Future work will focus on extending GNA to handle more complex graph types, such as Knowledge Graphs and heterogeneous networks, where edge labels and node attributes play a more significant role in the alignment process.
Summary updated