Improving Subgraph Matching by Combining Algorithms and Graph Neural Networks

Shuyang Guo, Wenjin Xie, Ping Lu, Ting Deng, Richong Zhang, Jianxin Li, Xiangping Huang, Zhongyi Liu · DOI

Abstract

Subgraph homomorphism (SHP) is a critical task in large-scale data mining and knowledge graph querying. Unlike subgraph isomorphism, SHP allows multiple pattern nodes to map to a single target node, creating a significantly larger search space. Traditional exact algorithms struggle with exponential runtimes, while standard Graph Neural Networks (GNNs) often fail to capture homomorphic structural nuances. This paper presents HFrame, a hybrid framework that integrates algorithmic pruning via DualSim with a specialized Homomorphic Neural Node Matching (HGIN) architecture. HFrame achieves an average accuracy of 96.2% and operates up to 101x faster than exact algorithms, demonstrating superior scalability and generalization across diverse real-world and synthetic datasets.

Introduction

In graph theory, identifying a specific pattern within a larger target graph is a fundamental operation. While much research has focused on subgraph isomorphism—where each node in a pattern must map to a unique node in the target—many real-world applications, such as querying knowledge graphs with SPARQL or Cypher, rely on subgraph homomorphism (SHP).

In SHP, the mapping constraint is relaxed: multiple vertices in the pattern can "collapse" onto the same vertex in the target graph. This flexibility significantly expands the search space, making traditional exact algorithms suffer from exponential runtimes due to heavy backtracking. Conversely, standard Graph Neural Networks (GNNs) struggle with SHP because their message-passing logic is typically designed for isomorphism, failing to distinguish between complex homomorphic and non-homomorphic structures.

The HFrame Framework

HFrame addresses these challenges through a "filter-then-predict" pipeline that combines the strengths of traditional algorithms and neural networks.

1. Algorithmic Pruning (DualSim)

Before the neural network processes the data, HFrame employs a polynomial-time algorithm called DualSim. This step acts as a pre-filter, quickly eliminating target nodes that cannot possibly match the pattern based on local connectivity. By drastically reducing the candidate pool, DualSim ensures the subsequent neural model only focuses on structurally plausible matches.

2. Homomorphic Neural Node Matching (HGIN)

The core of HFrame is HGIN, a custom GNN architecture designed specifically for homomorphism. It introduces several key innovations:

  • Sets over Multisets: Unlike standard GNNs that use multisets to count neighbors, HGIN utilizes sets. This allows the model to ignore duplicate messages, effectively mirroring the many-to-one mapping characteristic of homomorphism.
  • Cycle Awareness: The model explicitly incorporates cycle detection. If a pattern node belongs to a specific cycle (e.g., a triangle) that is absent in the target node's neighborhood, HGIN uses this structural mismatch to reject the candidate.
  • Order Embedding Space: HGIN maps nodes into an "order embedding" space. A match is predicted if the pattern node's vector is "smaller" than or equal to the target node's vector across all dimensions, providing a robust mathematical framework for the inclusion relationship.
The HFrame architecture illustrating the DualSim filtering and HGIN neural matching pipeline.

Experimental Evaluation

The researchers evaluated HFrame across a diverse set of benchmarks, including real-world academic networks (Citation, Citeseerx, DBLP), movie databases (IMDB), and large-scale knowledge graphs (DBpedia, YAGO). They also utilized synthetic graphs with up to 20 million nodes to test extreme scalability.

Key Results

  • Efficiency: HFrame demonstrated remarkable speed, running up to 101.91x faster than exact matching algorithms like EJ or PJ on large-scale graphs. While exact algorithms often timed out or encountered out-of-memory (OOM) errors on complex datasets like Citeseerx, HFrame processed queries in milliseconds.
  • Accuracy: The model achieved an average accuracy of 0.962, outperforming existing state-of-the-art machine learning models such as NeuroMatch and D2Match by approximately 21%.
  • Generalization: A significant finding was the model's ability to generalize. HFrame models trained exclusively on synthetic data maintained over 86% accuracy when tested on complex real-world datasets like IMDB and DBpedia.
Performance comparison of HFrame against exact algorithms and other neural matching methods across various datasets.

Conclusion and Future Work

HFrame demonstrates that the most effective approach to complex graph problems is often hybrid. By using DualSim as a pre-filter, the GNN can focus on the most difficult candidates, leading to superior accuracy and efficiency. While HFrame is currently optimized for the decision problem ("Does a match exist?"), it provides a powerful foundation for future work in subgraph enumeration. The authors suggest that HFrame's high-speed predictions could be used to further accelerate the extraction of all matching subgraphs in massive, dynamic databases.

Summary updated

BibTeX
@inproceedings{guo2025improving,
  author = {Shuyang Guo and Wenjin Xie and Ping Lu and Ting Deng and Richong Zhang and Jianxin Li and Xiangping Huang and Zhongyi Liu},
  title = {{Improving Subgraph Matching by Combining Algorithms and Graph Neural Networks}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2025},
  doi = {10.1145/3711896.3737006},
}
Figure