Abstract
Subgraph similarity search, one of the core problems in graph search, concerns whether a target graph approximately contains a query graph. The problem is recently touched by neural methods. However, current neural methods do not consider pruning the target graph, though pruning is critically important in traditional calculations of subgraph similarities. One obstacle to applying pruning in neural methods is the discrete property of pruning. In this work, we convert graph pruning to a problem of node relabeling and then relax it to a differentiable problem. Based on this idea, we further design a novel neural network to approximate a type of subgraph distance: the subgraph edit distance (SED). In particular, we construct the pruning component using a neural structure, and the entire model can be optimized end-to-end. In the design of the model, we propose an attention mechanism to leverage the information about the query graph and guide the pruning of the target graph. Moreover, we develop a multi-head pruning strategy such that the model can better explore multiple ways of pruning the target graph. The proposed model establishes new state-of-the-art results across seven benchmark datasets. Extensive analysis of the model indicates that the proposed model can reasonably prune the target graph for SED computation.
Introduction
Subgraph similarity search—determining if a target graph approximately contains a query graph—is a fundamental but computationally intensive task. The gold standard for measuring this is Subgraph Edit Distance (SED): the minimum number of edits (insertions, deletions, substitutions) needed to transform a query graph into a subgraph of a larger target. Calculating SED is NP-hard, and traditional algorithms rely heavily on "pruning" to discard irrelevant parts of the target graph.
Modern neural methods using Graph Neural Networks (GNNs) have largely ignored pruning because it is traditionally a discrete, "all-or-nothing" operation that breaks differentiability. Without pruning, neural models struggle when the target graph is significantly larger than the query, as they become "distracted" by irrelevant nodes and attempt to globalize the entire target structure into a single vector.
Methodology: Prune4SED
The authors propose Prune4SED, an end-to-end model that makes pruning differentiable by reformulating it as a node relabeling problem. Instead of deleting a node, the model multiplies its features by a "keep probability" ($\alpha$). This relaxation allows the pruning process to be trained via standard backpropagation.
The architecture consists of three main stages:
- Query-Aware Representation Learning (QAL): A cross-graph attention mechanism ensures target graph node representations are "aware" of the query graph's features. This prevents the model from processing the target in isolation.
- Neural Graph Pruning: The model employs a two-step pruning process:
- Hard Pruning: To maintain efficiency, the model initially keeps only the top-$k$ nodes (and their $h$-hop neighbors) based on the calculated $\alpha$.
- Soft Pruning: Continuous $\alpha$ values are applied to the remaining nodes, maintaining differentiability.
- Multi-head Prediction: Since there may be multiple valid ways to prune a graph to find a match, the model uses multiple pruning "heads" (similar to multi-head attention) and averages their predictions for a robust final SED score.
Experimental Results
Prune4SED was evaluated on seven diverse benchmark datasets across bioinformatics (AIDS, Protein), citation networks (CiteSeer, Cora_ML, DBLP, PubMed), and e-commerce (Amazon). Ground-truth SED values were generated using a mixed-integer programming solver (MIP-F2).
- Performance: Prune4SED established a new state-of-the-art, outperforming baselines like NeuroSED and SimGNN. On average, it reduced the Root Mean Square Error (RMSE) by 23% compared to the previous best neural models.
- Qualitative Analysis: Visualizations confirm the model successfully filters irrelevant structures. In molecular graphs, for instance, the model correctly prunes long carbon chains that do not match complex query structures.
- Efficiency: While the attention layers add some overhead compared to simple GNNs, Prune4SED remains orders of magnitude faster than traditional exact solvers while providing high accuracy.
Conclusion
By treating pruning as a differentiable relabeling task, Prune4SED bridges the gap between traditional algorithmic pruning and modern neural graph learning. The results suggest that spatial filtering via pruning is essential for accurate subgraph similarity computation, particularly as target graphs grow in size and complexity. Future work may extend this logic to explicitly handle edge labels and explore more specialized GNN architectures within the pruning framework.
Summary updated