Inquiry graph sub-graph and sub-graph matching method based on graph neural network

By partitioning the query graph using betweenness centrality, employing local modeling and a multi-round cross-attention mechanism, and combining this with reinforcement learning pruning strategies, the problems of smooth node representations and missing structural information in graph neural network subgraph matching are solved, thereby improving matching accuracy and efficiency.

CN120804162APending Publication Date: 2025-10-17NORTHEASTERN UNIV CHINA
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510958061.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing subgraph matching methods based on graph neural networks suffer from problems such as over-smoothing of node representation and missing global structural information, resulting in reduced matching accuracy and low computational efficiency.

Method used

A query graph partitioning strategy based on betweenness centrality is adopted, subgraphs are locally modeled through graph neural networks, and multi-round bidirectional cross-attention mechanism is used to fuse matching results. A reinforcement learning pruning strategy is introduced to optimize decision-making in the matching process.

Benefits of technology

It improves the accuracy and efficiency of subgraph matching, reduces computational complexity, and enhances the consistency and accuracy of matching results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804162A_ABST
    Figure CN120804162A_ABST
Patent Text Reader

Abstract

The invention provides a query graph sub-graph matching method based on a graph neural network, relates to the technical field of data processing, and aims to avoid direct global aggregation of a whole graph by adopting a query graph division strategy based on betweenness centrality so as to reduce the calculation complexity. By designing a multi-round bidirectional cross attention mechanism, the matching results of different sub-graphs are effectively fused, and the problems of node representation smoothing and global structure information loss in the existing method are solved, so that the consistency of the overall matching results is improved. By introducing the reinforcement learning pruning strategy, the decision in the matching process is adaptively optimized, so that the efficiency and precision of the algorithm in processing complex graph data are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a query graph subgraph matching method based on a graph neural network. BACKGROUND

[0002] Subgraph matching is one of the core tasks of graph data analysis, widely used in knowledge graph, bioinformatics, social network and other fields, aiming to effectively find substructures isomorphic to a given query graph from large-scale graph data. This task has significant theoretical and practical value, and its computational complexity has been proven to be NP-complete.

[0003] The initial subgraph matching method usually adopts an enumeration search method, which enumerates all possible mappings through backtracking search and reduces the amount of calculation by using pruning rules. Subsequently, researchers proposed algorithms based on indexing and filtering, which pre-constructed indexes to exclude a large number of impossible matching areas in advance, significantly improving the computational efficiency. In recent years, with the breakthrough of deep learning on graph data, new methods have emerged to solve subgraph matching or graph similarity judgment using graph neural networks. This kind of method jumps out of the traditional exact search framework, trying to transform subgraph matching into a learning problem, that is, through neural network to map graph data into low-dimensional vector representation, and then use the relationship between vectors to judge whether two graphs exist matching relationship, to realize fast approximate matching. Recently, reinforcement learning technology has been introduced into the subgraph matching task to optimize the search order and pruning decision, showing great potential and application prospect.

[0004] In the subgraph matching method based on graph neural network, finding the matching candidate node set of the query graph node in the data graph through the graph neural network is a popular research direction. Among them, the NeuroMatch algorithm decomposes the query graph and the data graph into small subgraphs, and uses the graph neural network to obtain the feature representation of the graph, and then captures the geometric constraints corresponding to the subgraph relationship through training, and finally performs subgraph matching operation in the state space. Specifically, the model first decomposes the target graph and the query graph into smaller subgraphs, which helps to reduce the complexity of matching and embed the subgraphs into a high-dimensional space that can be processed by the neural network. Then NeuroMatch embeds these small subgraphs through the graph neural network, which can capture the relationship between nodes in the graph, structural information and local features, thereby effectively representing the structure of the graph. In the embedding space, NeuroMatch uses geometric constraints to align the subgraphs of the query graph and the target graph. This constraint ensures that the relative position and relationship between subgraphs are effectively preserved in the embedding space, enhancing the accuracy of matching. Using node embedding, the NeuroMatch model can efficiently find the matching candidate node set. In contrast, the Sub-GMN algorithm directly obtains a matching matrix representing the matching candidate node set based on the graph neural network, rather than obtaining a node embedding vector representation. The model first uses a graph representation learning method to map the nodes in the graph to node-level embedding vectors. In this model, a graph convolutional network is used to learn node representation. The graph neural network updates the representation of each node by aggregating the information of neighboring nodes, so that it contains the features and structural information of the node. After obtaining the node embedding, a neural tensor network is used to calculate the similarity between node pairs. At the same time, an attention mechanism is introduced to dynamically focus on important node pair relationships to enhance the expression ability of the model. Finally, the model generates a matching matrix representing the node matching relationship between the query graph and the data graph, which provides node-to-node matching information and helps to identify the structural similarity between graphs.

[0005] The existing subgraph matching method based on graph neural network generally has the problem of over-smoothing of node representation, that is, as the number of GNN layers increases, the node representation converges, making it difficult to distinguish the features of nodes in different structural positions. In addition, existing methods usually only focus on the aggregation of local neighborhood features of nodes, lack effective capture of global key structural information of the graph, and are difficult to accurately identify and match important structural features in complex graph data. This limitation directly leads to a significant reduction in matching accuracy, severely limiting the effectiveness of practical applications. SUMMARY

[0006] In view of the deficiencies of the prior art, the purpose of the present application is to provide a query graph subgraph matching method based on graph neural network, comprising: Step 1: Get the query graph input by the user and get the data graph corresponding to the query graph, which includes multiple nodes ,node The data graph includes multiple nodes v, and the nodes v are connected by edges; Step 2: Divide the query graph by betweenness centrality to obtain multiple query subgraphs; Step 3: For each query subgraph, calculate the local matching matrix between the query subgraph and the data graph , and then obtain multiple local matching matrices; Step 4: Based on the local matching matrix , calculate the global matching matrix ; Step 5: Based on the global matching matrix , generate the initial hard matching matrix; Step 6: Based on the initial hard matching matrix, train the policy network and value network to obtain the trained policy network; Step 7: Obtain the query graph newly input by the user, execute steps 1-5, obtain the initial hard matching matrix, generate a state vector based on the initial hard matching matrix, input the state vector into the trained policy network, generate pruning actions in rounds and execute pruning until the entire pruning process is completed, and obtain the retained candidate data graph node corresponding to each query graph node.

[0007] Optionally, step 2 specifically includes: For each node in the query graph , computing nodes Betweenness centrality , which is specifically achieved through the following formula: ; in, Represents a node in the query graph s To Node t The number of paths between which the path length is the target path length, where the target path length is the number of nodes s To Node t The shortest path length between Indicates that in a path whose path length is the target path length, it passes through the node The number of paths; Among the betweenness centralities of all nodes, obtain the node corresponding to the largest betweenness centrality, use the node as the core node, obtain multiple nodes directly connected to the core node through edges, and form a query subgraph with the nodes directly connected to the core node through edges, the core node, and the edges connecting the nodes. Delete the nodes of the query subgraph from all the nodes in the query graph, and return the node corresponding to the largest betweenness centrality among all the remaining nodes, thereby obtaining multiple query subgraphs.

[0008] Optionally, step 3 specifically includes: Step 3.1: Query subgraph Each node u and each node of the data graph v Input into the same GNN respectively to get the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v ; Step 3.2: Based on the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v , calculate the local matching matrix , and then obtain multiple local matching matrices; Step 3.2.1: Calculate each node in the query subgraph u And each node in the data graph v The similarity between , which is specifically achieved through the following formula: ; in, represents vector concatenation, W is a learnable parameter; Step 3.2.2: Based on similarity , computing nodes u and nodes v The matching probability between , which is specifically achieved through the following formula: ; in, Represents a collection of data graph nodes, Represents a query subgraph node u and data graph nodes similarity; Local matching matrix of the matching probability between each node in the query subgraph and each node in the data graph , and then obtain multiple local matching matrices.

[0009] Optionally, step 4 specifically includes: Step 4.1: Compute the query subgraph S i and query subgraph S j The comprehensive similarity between ; Step 4.2: Based on comprehensive similarity , calculate the query subgraph S i The attention weight and query subgraph S j The attention weight , which is specifically achieved through the following formula: ; ; in, Query subgraph S i and query subgraph S k The comprehensive similarity between Query subgraph S j and query subgraph S k The comprehensive similarity between Step 4.3: Perform multiple iterations on the attention weight of the query subgraph and the embedding vector of the query subgraph to obtain the final embedding vector and the final attention weight of the query subgraph; Step 4.4: Final attention weight and local matching matrix based on query subgraph , calculate the global matching matrix ; Specifically, based on the final attention weight of the query subgraph, the fusion coefficient is calculated , which is specifically achieved through the following formula: ; ; Among them, Z is the intermediate variable, K is the total number of query subgraphs, Query subgraph S i The final attention weight, Query subgraph S j Final attention weights; According to the fusion coefficient and the local matching matrix , the global matching matrix is calculated , wherein the global matching matrix contains a plurality of confidences, and is specifically realized by the following formula: .

[0010] Optionally, step 4.1 specifically includes: Step 4.1.1: obtaining a query subgraph S i , , wherein , m i represents the total number of nodes in the query subgraph S i , represents the first node in the query subgraph S i , represents the nth node in the query subgraph S i ; m i obtaining a node set S j of the query subgraph , , wherein m j represents the total number of nodes in the query subgraph S j , represents the first node in the query subgraph S j , represents the nth node in the query subgraph S j ; m j Step 4.1.2: calculating the similarity between the nodes of the query subgraph S i and the nodes of the query subgraph S j , and the calculation is specifically realized by the following formula: ; wherein is a node in the node set , is an embedding vector of , is a node in the node set , is The embedding vector of T represents transpose, Representation node and nodes similarity; Compute query subgraph S i Each node and query subgraph S j The similarity between each node is obtained to obtain the similarity matrix; Step 4.1.3: Query subgraph S i For each node in the similarity matrix, get the node Corresponding to multiple similarities, among the multiple similarities, the similarity with the largest value is obtained as the first similarity, and then each node Get a first similarity, calculate the average of all similarities, and get the node alignment score , specifically expressed by the following formula: ; Step 4.1.4: Based on node alignment score Calculate comprehensive similarity , which is specifically achieved through the following formula: ; in, Represents a query subgraph S i Embedding vector and query subgraph of S j The similarity of the embedding vectors of β is a hyperparameter.

[0011] Optionally, step 4.3 specifically includes: Step 4.3.1: Set the initial number of iterations l = 0, and use the embedding vectors of all nodes in the query subgraph as l = 0, the embedding vector of the query subgraph is used as the attention weight of the query subgraph l =0 when the attention weight of the query subgraph is Step 4.3.2: Update the embedding vector of the query subgraph based on the attention weights of all query subgraphs. This is achieved by the following formula: ; in, l represents the number of iterations, Indicates the l +1 iteration to query the subgraph S i The embedding vector of For the l Iteration , Indicates the l Iteration query subgraph S j Embedding vector of Step 4.3.3: Add one to the current number of iterations to determine whether the embedding vector of the query subgraph converges or whether the number of iterations reaches the preset threshold. If the embedding vector of the query subgraph converges or the number of iterations reaches the preset threshold, the first l The embedding vector of the query subgraph in the +1 iteration is used as the final embedding vector of the query subgraph, and the l The attention weight of the query subgraph in the iteration is used as the final attention weight of the query subgraph. If the embedding vector of the query subgraph does not converge and the number of iterations does not reach the preset threshold, execute steps 4.1, 4.2, 4.3.2 and 4.3.3.

[0012] Optionally, step 5 specifically includes: Step 5.1: Based on the preset threshold Global matching matrix To process, specifically, the global matching matrix Greater than or equal to the preset threshold The confidence level is set to 1, and the global matching matrix Less than the preset threshold The confidence of is set to 0, and the first hard matching matrix is ​​obtained. ; Step 5.2: Based on the first hard matching matrix , calculate the target threshold , which is specifically achieved through the following formula: ; in, For all node pairs Seek hope, represents the first hard matching matrix Middle Rank v The confidence level of the column, express The true matching label of To pass the cross entropy loss function, and The calculated loss value; Step 5.3: Based on target threshold , calculation dynamics The value is realized by the following formula: ; in, represents the maximum value of the betweenness centrality of all nodes in the query graph; In the global matching matrix , get the node All corresponding confidence levels, get the previous one among all confidence levels confidence, and obtain the previous The confidence level corresponds to the data graph node, and the node Before The confidence levels of the data graph nodes corresponding to the first set are used to form a first set, and then the first set corresponding to each query graph node is obtained; Based on the first set corresponding to each query graph node, a second hard matching matrix is ​​generated. Specifically, the values ​​of the corresponding positions of the data graph nodes corresponding to the query graph nodes in the first set in the matrix are set to 1, and the values ​​of the other positions are set to 0, thereby obtaining the second hard matching matrix. For the case where a data graph node corresponds to multiple query graph nodes in the second hard matching matrix, the data graph node is regarded as a conflict node, and for each conflict node , get all the corresponding query graph nodes, and use all the corresponding query graph nodes as candidate nodes. All candidate nodes of each conflicting node form a conflict set ; Compute conflict sets Each candidate node in Comprehensive scoring indicators , which is specifically achieved through the following formula: ; in, represents the global matching matrix Middle Rank The confidence of the column, that is, the candidate node Conflict Node Confidence of the match; In the conflict set In the query graph, all candidate nodes have a comprehensive scoring index corresponding to them, and the candidate node with the largest comprehensive scoring index is obtained, which is used as the query graph node that is the only match for the conflicting node. Thus, the query graph node that uniquely matches each conflicting node is determined, and an initial hard matching matrix is ​​generated. Specifically, the values ​​of the corresponding positions of the conflicting node and the uniquely matching query graph node in the matrix are set to 1, and the values ​​of other positions are set to 0 to obtain the initial hard matching matrix.

[0013] Optionally, step 6 specifically includes: Step 6.1: Define pruning actions and construct a legal action space based on the initial hard matching matrix; The pruning action is to delete the matched query graph nodes and data graph nodes in the initial hard matching matrix, that is, to set the confidence corresponding to the query graph nodes and data graph nodes in the initial hard matching matrix to 0. The legal action space includes a set of query graph nodes and data graph node pairs that can perform pruning actions, wherein the query graph nodes and data graph node pairs that can perform pruning actions have a confidence of 1 in the initial hard matching matrix. Step 6.2: Initialize the parameters of the policy network in the agent and the parameters in the value network, and set the initialized policy network as the current policy network and the initialized value network as the current value network. Step 6.3: Set the initial hard matching matrix as the dynamic matching matrix, set the initial pruning round number as the current pruning round number t. Step 6.4: Based on the legal action space and the dynamic matching matrix, set the dynamic mask vector. Specifically, for the pruning action in the legal action space, the mask of the pruning action with a value of 0 in the dynamic matching matrix is set to 0; among all query graph nodes, the top 10% query graph nodes in the betweenness centrality are regarded as key hub nodes, and when the number of pruning actions corresponding to the key hub is 1, the mask of the pruning action is set to 0. The masks of all pruning actions form the dynamic mask vector. Step 6.5: According to the dynamic matching matrix, construct the state vector of the tth round ; Step 6.6: Based on the state vector and the current policy network, obtain the current pruning action , execute the current pruning action , and set the corresponding position in the dynamic matching matrix to 0 to obtain a new dynamic matching matrix. Wherein, based on the state vector and the current policy network, the current pruning action is obtained, including: Input the state vector of the tth round into the current policy network to obtain the initial probability distribution of all pruning actions in the legal action space. The initial probability distribution is corrected by the dynamic mask vector. Specifically, the probability of the pruning action with a mask of 0 in the initial probability distribution is set to 0 to obtain a corrected probability distribution. The corrected probability distribution is normalized to obtain a target probability distribution. The target probability distribution is sampled by a sampling method to obtain the current pruning action , the current pruning action corresponding node pair is recorded as , the query graph node corresponding to the current pruning action , The current pruning action The corresponding data graph node; Step 6.7: Calculate the current pruning action Total Rewards ; Step 6.8: , , , ) is stored as a trajectory sample in the experience pool, the current pruning round number t is increased by one, and step 6.4 is executed again based on the new dynamic matching matrix until the pruning round number reaches the preset threshold. All trajectory samples constitute the training set; Step 6.9: Based on the training set, use the PPO policy optimization algorithm to jointly update the parameters of the current policy network and the current value network. Return to step 6.3 and continue until the number of parameter updates reaches the preset number, or the loss value of the policy network after two trainings is less than the preset threshold, or the average of the total rewards of the policy network on the validation set exceeds the preset threshold. The trained policy network is obtained.

[0014] Optionally, step 6.5 specifically includes: Step 6.5.1: Compute the global embedding vector of the query graph , which is specifically achieved through the following formula: ; in, Representing a query graph The set of all nodes in Indicates that the query graph As input, the nodes output by the graph neural network GNN The embedding vector of It is a graph-level aggregation function; Step 6.5.2: Calculate the local subgraph embedding vector , which is specifically achieved through the following formula: ; in, represents the query graph node corresponding to the t-1th round of pruning action, To query the graph with nodes The set of directly connected nodes, for A node in Indicates that The corresponding graph is used as input and the nodes output by the graph neural network GNN are The embedding vector of Indicates that the mean pooling operation is performed on all node embedding vectors; Step 6.5.3: Expanding the dynamic matching matrix to obtain a feature vector by a sparse coding method ; Step 6.5.4: Calculating a structure violation heat vector H; Specifically, according to the dynamic matching matrix, all data graph nodes corresponding to the query graph nodes are determined, for each query graph node, the number of edges directly connected to the query graph node in the query graph is obtained to obtain a first value, for each data graph node corresponding to the query graph node, the number of edges directly connected to the data graph node in the data graph node is obtained to obtain a second value, and then a plurality of second values are obtained, the ratio of each second value to the first value is calculated to obtain a plurality of edge existence rates, the average value of all edge existence rates is calculated, the average value is inverted and normalized to obtain a structure violation heat value , the structure violation heat values of all query graph nodes comprise the structure violation heat vector; Step 6.5.5: Splicing the global embedding vector of the query graph , the local subgraph embedding vector , the feature vector and the structure violation heat vector H to obtain the state vector of the t-th round , which is specifically represented by the following formula: .

[0015] Optionally, step 6.7 specifically includes: Step 6.7.1: Calculating the matching accuracy reward of the current pruning action , which is specifically implemented by the following formula: ; Wherein, denotes the confidence of the query graph node and the data graph node in the global matching matrix , denotes an indicator function, which takes a value of 1 when the condition in the parentheses is satisfied, and 0 otherwise, is a label matching matrix, denotes the true matching label of the query graph node and the data graph node in the label matching matrix, denotes that the query graph node and the data graph node are matched, denotes that the query graph node and the data graph node are not matched, to punish the weight coefficient; Step 6.7.2: Calculate the structural consistency reward of the current pruning action , which is realized by the following formula: ; denotes the query graph node in the t-1th round of structural violation heat value, denotes the query graph node in the tth round of structural violation heat value, denotes the reward intensity, which is calculated by the following formula: ; is the basic weight coefficient, denotes the betweenness centrality of the query graph node , and denotes the maximum value in the betweenness centrality of all nodes in the query graph; Step 6.7.3: Calculate the node importance reward of the current pruning action , which is realized by the following formula: ; is the node importance punishment coefficient, is the betweenness centrality threshold, is the global matching confidence threshold; Step 6.7.4: Calculate the sparsity reward of the current pruning action , which is realized by the following formula: ; denotes the sparsity punishment coefficient, denotes the number of data graph nodes corresponding to the query graph node in the new dynamic matching matrix, and k is a preset upper threshold; Step 6.6.5: Calculate the terminal reward of the current pruning action , which is realized by the following formula: ; denotes the weight coefficient of the terminal reward, denotes the F1 score, which comprehensively considers the recall rate and precision rate of the pruning result; Step 6.7.6: Calculate the terminal reward of the current pruning action ​​​​​​​​​Total reward , specifically by the following formula: .

[0016] The beneficial effects produced by the above technical solution are: The application provides a query graph subgraph matching method based on a graph neural network. By adopting a query graph division strategy based on betweenness centrality, direct global aggregation of the whole graph is avoided, so that the calculation complexity is reduced. By designing a multi-round bidirectional cross attention mechanism, the matching results between different subgraphs are effectively fused, the problems of node representation smoothing and global structure information loss of existing methods are overcome, and the consistency of the overall matching result is improved. By introducing a reinforcement learning pruning strategy, the decision in the matching process is adaptively optimized, so that the efficiency and accuracy of the algorithm in processing complex graph data are improved. BRIEF DESCRIPTION OF DRAWINGS

[0017] Figure 1 Fig. 1 is a flowchart of a query graph subgraph matching method based on a graph neural network in an embodiment of the application; Figure 2 Fig. 2 is a structure diagram of a subgraph matching method based on query graph division in an embodiment of the application; Figure 3 Fig. 3 is a schematic diagram of a hierarchical coverage method in an embodiment of the application; Figure 4 Fig. 4 is a schematic diagram of a global aggregation method in an embodiment of the application. DETAILED DESCRIPTION

[0018] The specific embodiments of the application will be further described in detail below in conjunction with the drawings and examples. The following examples are used to illustrate the application, but are not used to limit the scope of the application.

[0019] In the optimization of subgraph matching algorithms, reinforcement learning (RL) techniques have shown unique advantages in recent years. Unlike supervised learning, which directly predicts matching results, reinforcement learning focuses on optimizing decision strategies, which is well suited for many sequential decision-making problems in subgraph matching, such as determining the matching order of query vertices, branch selection and pruning strategies during the search process, etc. The RL-OVO model first combines deep reinforcement learning and graph neural networks. Based on reinforcement learning for query vertex ordering, the model models the query vertex selection process as a step-by-step decision-making process. At each state (including the currently matched vertices and the remaining candidates), the policy network selects the next query vertex to be matched. The policy network uses a graph neural network to extract features of the current matching state and is trained through reinforcement learning to maximize the cumulative reward of the final matching efficiency. Unlike fixed heuristics, the RL model can adaptively determine the matching order based on the specific query graph and data graph characteristics, allowing it to adopt different strategies for different queries. After extensive training, the model learns to balance local and global information, selecting sequences that can quickly narrow down candidates without missing correct solutions due to premature pruning. Experimental results show that, compared to the state-of-the-art heuristic algorithm, the RL-generated sequence reduces the average computation time for matching queries by up to two orders of magnitude. This achievement demonstrates the great potential of reinforcement learning in optimizing subgraph matching search.

[0020] To solve the problems of node representation over-smoothing, insufficient structure information capture, and low computational efficiency in the prior art, the present application provides a query graph subgraph matching method based on a graph neural network. By using a centrality-based query graph division strategy, direct global aggregation of the entire graph is avoided, thereby reducing computational complexity. By designing a multi-round bidirectional cross-attention mechanism, the matching results between different subgraphs are effectively fused, overcoming the problems of node representation smoothing and lack of global structure information in existing methods, thereby improving the consistency of the overall matching result. By introducing a reinforcement learning pruning strategy, the decision-making process during matching is adaptively optimized, thereby improving the efficiency and accuracy of the algorithm when processing complex graph data.

[0021] Specifically, the present application proposes a subgraph matching algorithm framework that integrates query graph division, graph neural modeling, and reinforcement learning optimization to address the challenges of over-smoothing caused by deep aggregation of graph neural networks and limited structure representation. The method includes four core modules: graph division, local modeling, subgraph fusion, and strategy pruning. (1) A query graph partitioning method based on betweenness centrality is proposed. High centrality nodes are used as the partitioning core, and the original query graph is partitioned into multiple subgraphs with compact structure and clear boundaries through a hierarchical coverage strategy. This partitioning method not only preserves the key topological structure of the original graph, but also effectively limits the receptive field range of GNN, alleviating the problem of over-smoothing caused by deep aggregation.

[0022] (2) Introduce local modeling module. After subgraph partitioning, the invention uses graph neural network to model each subgraph, extracts structural features through local node aggregation operation, and generates embedding representation. These representations are used to calculate the similarity between the query subgraph and the data graph, and to construct the preliminary matching matrix, providing a basis for subsequent matching fusion.

[0023] (3) A multi-round bidirectional attention fusion mechanism is designed to address the information fragmentation problem between multiple subgraph matching results. This mechanism fuses multiple local matching matrices through node alignment and cross comparison to enhance the relevance and consistency of the matching results. In each round of fusion, the matching information of each subgraph interacts and updates within the local range, which helps to alleviate the structure dispersion problem caused by partitioning. Unlike the traditional simple result splicing method, this mechanism can adjust the information at a fine-grained level based on the structural relevance between subgraphs, making the fusion result more coherent. In addition, the multi-round iterative fusion method also provides space for local conflict coordination, through repeated information update and attention adjustment, the final global matching matrix is optimized in terms of structure preservation and similarity consistency. This module plays a key role in integrating local matching and improving global accuracy, and is an important part of the invention method.

[0024] (4) Introduce a pruning strategy based on reinforcement learning to improve the accuracy of the matching results. The invention prunes and optimizes redundant or uncertain candidate nodes in the local matching results. This strategy dynamically adjusts the pruning decision by learning the reward signal, effectively improving the quality and efficiency of the final matching results. As a post-processing step in the entire process, the pruning mechanism further enhances the selectivity and stability of the matching process.

[0025] In combination with Figure 1 and Figure 2 , the query graph subgraph matching method based on graph neural network provided by the invention can include the following steps: Step 1: Obtain the query graph input by the user, and obtain the data graph corresponding to the query graph, the query graph includes multiple nodes , nodes are connected by edges, the data graph includes multiple nodes v , nodes v are connected by edges; Step 2: divide the query graph into multiple query subgraphs by betweenness centrality; Specifically, for each node in the query graph , the betweenness centrality of the node is calculated , which is realized by the following formula: ; Wherein, denotes the number of paths with a target path length between node s and node t , and the target path length is the shortest path length between node s and node t , denotes the number of paths passing through node in the path with the target path length. Among the betweenness centralities of all nodes, the node corresponding to the maximum betweenness centrality is obtained, the node is taken as a core node, multiple nodes directly connected to the core node through edges are obtained, the nodes directly connected to the core node through edges, the core node, and the edges connected between the nodes are combined to form a query subgraph, the nodes of the query subgraph are deleted from all nodes of the query graph, and the node corresponding to the maximum betweenness centrality is returned in the remaining all nodes. Further multiple query subgraphs are obtained. Through this greedy multi-round iteration, the overall coverage of the query graph can be gradually realized, and it is ensured that each query subgraph is developed around a high centrality node.

[0026] In combination with Figure 3 , Figure 3 the query graph above, A-K and X represent query graph nodes, and the numbers in the query graph nodes are the betweenness centralities calculated according to the above calculation formula. In combination with the above division method, the node with the maximum betweenness centrality is obtained as X, the nodes directly connected to X through edges are H, K, and C, and further a query subgraph Q1 is obtained. The nodes of the query subgraph Q1 are deleted from all nodes of the query graph, the node with the maximum betweenness centrality in the remaining all nodes is node A, the nodes directly connected to node A through edges are C, B, E, and D, and further a query subgraph Q2 is obtained. The nodes of the query subgraph Q2 are deleted from all nodes of the query graph, the node with the maximum betweenness centrality in the remaining all nodes is node G, the nodes directly connected to node G through edges are I, F, and H, and further a query subgraph Q3 is obtained. Finally, three query subgraphs Q1, Q2, and Q3 are obtained.

[0027] Among them, the betweenness centrality index is used to select high centrality nodes in the graph as core hubs, and hierarchical partitioning is performed to decompose the query graph into multiple local subgraphs, retaining key structural features and controlling the subgraph scale, thereby reducing subsequent computing overhead.

[0028] Step 3: For each query subgraph, calculate the local matching matrix between the query subgraph and the data graph , and then obtain multiple local matching matrices; By embedding the nodes in the query subgraph and the data graph using a graph neural network, we can obtain a high-dimensional representation of each node. Then, by calculating the similarity between the query subgraph nodes and the data graph nodes, we can obtain the matching degree between the query subgraph and the data graph. This process ensures that the similarity between local structures can be accurately captured, thereby providing precise local matching information for subsequent global aggregation. Specifically, it includes the following steps: Step 3.1: Query subgraph Each node u and each node of the data graph v Input into the same GNN respectively to get the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v ; Among them, the query subgraph node at a certain layer in GNN u The update of the embedding vector is calculated as follows: ;

[0029] in express u The set of directly connected nodes, Represents an aggregate function, Represents a query graph node u In the l +1 layer embedding vector, Indicates the l The learnable weight matrix of the layer, where the data graph nodes v The embedding vector of is updated in the same way.

[0030] Step 3.2: Based on the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v , calculate the local matching matrix , and then obtain multiple local matching matrices; Step 3.2.1: Calculate the similarity between each node in the query subgraph u and each node in the data graph v , specifically by the following formula: ; wherein denotes vector concatenation, W is a learnable parameter; It should be noted that if a nonlinear similarity is required, an activation function can be added after the similarity is calculated.

[0031] Step 3.2.2: Based on the similarity , calculate the matching probability u between node v and node , specifically by the following formula: ; wherein denotes the set of data graph nodes, denotes the similarity between the query subgraph node u and the data graph node ; The local matching matrix of the matching probability of each node in the query subgraph and each node in the data graph , the size of which is , wherein denotes the total number of nodes in the query subgraph, denotes the total number of nodes in the data graph, and thus a plurality of local matching matrices are obtained.

[0032] Step 4: Based on the local matching matrix , calculate the global matching matrix ; It is known that after completing the independent matching of each query subgraph and the data graph , a plurality of local matching matrices can be obtained., but these query subgraphs have structural overlap or functional complementarity, and it is difficult to fully utilize the local information of each query subgraph by relying solely on simple splicing or averaging in existing methods. The present invention identifies the structural and semantic associations between query subgraphs from the two aspects of similarity measurement and attention aggregation, and integrates the matching information from the node to the entire query subgraph step by step. First, for each pair of query subgraphs, the dot product based on node-level embedding is used to measure the fine-grained semantic consistency, generate an alignment score matrix, and take the maximum value average by row to obtain the correlation strength between the query subgraphs. Secondly, combining the similarity and alignment score of the query subgraph embedding, bidirectional attention weights are generated through Softmax to quantify the complementarity and credibility between query subgraphs. Finally, through multiple rounds of updates represented by the query subgraph, the information of the high-weight query subgraph is gradually enhanced in the iteration, and finally all local matching matrices are weighted and aggregated to generate a globally consistent matching result, combined with Figure 4 , specifically including the following steps: Step 4.1: Compute the query subgraph S i and query subgraph S j The comprehensive similarity between , to evaluate the structural and feature similarities between query subgraphs. These similarities reflect the potential correlation between different query subgraphs and provide support for the subsequent multi-round bidirectional attention aggregation mechanism; Step 4.1.1: Get the query subgraph S i Node set , ,in, m i Represents a query subgraph S i The total number of nodes, Represents a query subgraph S i The first node in Query subgraph S i The m i nodes; get the query subgraph S j Node set , ,in, m j Represents a query subgraph S j The total number of nodes, Represents a query subgraph S j The first node in Query subgraph S jThe m j nodes; Step 4.1.2: Compute the query subgraph S i Nodes and query subgraphs S j The similarity between nodes is specifically achieved through the following formula: ; in, For node sets The nodes in for The embedding vector of For node sets The nodes in for The embedding vector of T represents transpose, Representation node and nodes similarity; Compute query subgraph S i Each node and query subgraph S j The similarity between each node is obtained by combining the similarity matrix Figure 4 , the similarity matrix can be represented by a graph, that is Figure 4 Node alignment heatmap in , where u 11 、 u 12 ,and u 13 is the node of query subgraph Q1, u 21 、 u 22 ,and u 23 is the node of query subgraph Q2.

[0033] Step 4.1.3: Query subgraph S i For each node in the similarity matrix, get the node Corresponding to multiple similarities, among the multiple similarities, the similarity with the largest value is obtained as the first similarity, and then each node Get a first similarity, calculate the average of all similarities, and get the node alignment score , specifically expressed by the following formula: ; Step 4.1.4: Based on node alignment score Computing the comprehensive similarity , specifically by the following formula: ; wherein, denotes the similarity between the embedding vector of the query subgraph S i and the embedding vector of the query subgraph S j , β is a hyperparameter, can be regarded as a hyperparameter, if the node alignment is good (large ), the similarity will be significantly raised, otherwise it will remain near the baseline value.

[0034] To integrate multiple subgraph matching results, a bidirectional cross attention mechanism is introduced to align and fuse the node matching results between different subgraphs, and a global matching matrix is constructed, which is specifically implemented by the following steps.

[0035] Step 4.2: Based on the comprehensive similarity , the attention weight S i of the query subgraph and the attention weight S j of the query subgraph are calculated, which is specifically implemented by the following formula: ; ; wherein, is the comprehensive similarity between the query subgraph S i and the query subgraph S k , is the comprehensive similarity between the query subgraph S j and the query subgraph S k ; Step 4.3: The attention weight of the query subgraph and the embedding vector of the query subgraph are updated multiple times to obtain the final embedding vector of the query subgraph and the final attention weight of the query subgraph; Step 4.3.1: Set the initial iteration number l =0, the embedding vector of all nodes of the query subgraph is taken as l =0, the embedding vector of the query subgraph is taken as l =0, the attention weight of the query subgraph is taken as Step 4.3.2: Update the embedding vector of the query subgraph based on the attention weight of all query subgraphs, which is realized by the following formula: ; Wherein, l represents the number of iterations, represents the embedding vector of the query subgraph in the l +1th iteration, S i ; is the embedding vector of the query subgraph in the l th iteration, , represents the embedding vector of the query subgraph in the l +1th iteration. S j ; Step 4.3.3: Increase the current iteration number by one, and judge whether the embedding vector of the query subgraph converges or the number of iterations reaches the preset threshold. In the case that the embedding vector of the query subgraph converges or the number of iterations reaches the preset threshold, the embedding vector of the query subgraph in the l +1th iteration is taken as the final embedding vector of the query subgraph, and the attention weight of the query subgraph in the l th iteration is taken as the final attention weight of the query subgraph. In the case that the embedding vector of the query subgraph does not converge and the number of iterations does not reach the preset threshold, steps 4.1, 4.2, 4.3.2 and 4.3.3 are executed.

[0036] Combined with the attention mechanism learning in Figure 4 , the attention weight between query subgraph Q1 and query subgraph Q2 is calculated as =0.7 in the first iteration, and then the second iteration is performed. The attention weight between query subgraph Q1 and query subgraph Q2 is calculated as =0.5 in the second iteration, and the final attention weight is obtained after multiple iterations.

[0037] Step 4.4: Based on the final attention weight of the query subgraph and the local matching matrix , the global matching matrix is calculated.

[0038] Specifically, based on the final attention weight of the query subgraph, the fusion coefficient is calculated, which is realized by the following formula: ; ; Wherein, Z is an intermediate variable, K is the total number of query subgraphs, is the query subgraph S iFinal attention weight, For query subgraph S j Final attention weight; According to the fusion coefficient And the local matching matrix , the global matching matrix is calculated , wherein the global matching matrix contains a plurality of confidence values, which are realized by the following formula: ; As Figure 4 , the global matching matrix is obtained, and the contribution weight of each query subgraph in the global matching matrix is further seen.

[0039] The present application proposes a two-stage hard matching strategy, aiming to effectively realize the actual matching application of the query subgraph, to solve the problem of the existing soft matching result in the actual application. The soft matching result represents the matching relationship between the query node and the data node in the form of a probability value matrix, but such a matrix is difficult to be directly used in actual application scenarios, so it is necessary to convert the probability value into a binary result of explicit matching or not. In the two-stage hard matching conversion, the first stage introduces a dynamic candidate reservation mechanism, which adaptively adjusts the number of candidates according to the node betweenness centrality index, and preferentially reserves the matching of the hub node to maintain the topological robustness. The second stage introduces a topology-guided conflict resolution, which combines confidence weight and node importance quantification to solve redundant conflicts and strengthen global structural consistency, which is realized by step 5.

[0040] Step 5: based on the global matching matrix , an initial hard matching matrix is generated; Step 5.1: according to the preset threshold , the global matching matrix is processed, specifically, the confidence values in the global matching matrix greater than or equal to the preset threshold are set to 1, and the confidence values in the global matching matrix less than the preset threshold are set to 0, to obtain a first hard matching matrix ; Step 5.2: based on the first hard matching matrix , a target threshold is calculated, which is realized by the following formula: ; Wherein, represents the expectation of all node pairs , and represents the first hard matching matrix the first row v confidence, represent the real matching label, is obtained by calculating the loss value of and through the cross-entropy loss function; The method converts the global matching matrix into the first hard matching matrix in turn by traversing different candidate thresholds on the training data set, and calculates the error between the first hard matching matrix and the real matching label. By introducing the loss function to measure the consistency between the first hard matching matrix and the real label, the threshold that can minimize the overall loss is finally selected as the optimal threshold. This strategy can automatically determine the most reasonable dividing standard in soft-hard matching conversion under the supervision of training data, thereby improving the final matching accuracy and stability.

[0041] Step 5.3: Based on the target threshold , the dynamic value is calculated, which is realized by the following formula: ; Wherein, represents the maximum value in the betweenness centrality of all nodes in the query graph; Wherein, in the specific implementation process, the dynamic value is adaptively adjusted according to the betweenness centrality of the query node. For hub nodes with high centrality, the number of reserved candidate nodes is increased to ensure the connectivity of key structures; while for edge nodes, redundant matching is strictly limited to reduce the complexity and computational cost of subsequent processing.

[0042] In the global matching matrix , all confidences corresponding to the node are obtained, the first confidences are obtained in all confidences, and the first data graph nodes corresponding to the first confidences of the node are obtained to form a first set, and then the first set corresponding to each query graph node is obtained; Based on the first set corresponding to each query graph node, a second hard matching matrix is generated. Specifically, the data graph nodes corresponding to the query graph nodes in the first set are set to 1 in the corresponding position of the matrix, and the values of other positions are set to 0 to obtain the second hard matching matrix; For the case that one data graph node corresponds to multiple query graph nodes in the second hard matching matrix, the data graph node is taken as a conflict node, and for each conflict node , get all the corresponding query graph nodes, and use all the corresponding query graph nodes as candidate nodes. All candidate nodes of each conflicting node form a conflict set ; Compute conflict sets Each candidate node in Comprehensive scoring indicators , which is specifically achieved through the following formula: ; in, represents the global matching matrix Middle Rank The confidence of the column, that is, the candidate node Conflict Node Confidence of the match; In the conflict set In the query graph, all candidate nodes have a comprehensive scoring index corresponding to them, and the candidate node with the largest comprehensive scoring index is obtained, which is used as the query graph node that is the only match for the conflicting node. Thus, the query graph node that uniquely matches each conflicting node is determined, and an initial hard matching matrix is ​​generated. Specifically, the values ​​of the corresponding positions of the conflicting node and the uniquely matching query graph node in the matrix are set to 1, and the values ​​of other positions are set to 0 to obtain the initial hard matching matrix.

[0043] In summary, the generation process of the global matching matrix requires selecting key nodes in the graph through the betweenness centrality indicator and partitioning the graph based on these nodes. After generating local matches, the cross-subgraph attention mechanism is introduced to fuse multiple local subgraph matching results, and finally the matching information of all subgraphs is integrated through the global matching matrix. Figure 4 This is a structural diagram of the subgraph matching method based on query graph partitioning that combines the above steps.

[0044] The invention not only gradually corrects redundant matching and strengthens topological constraints through a serialized decision-making mechanism, but also introduces node importance weights and edge constraint-sensitive reward mechanisms to achieve the purpose of prioritizing the protection of hub node matching stability and guiding the pruning process to iterate towards topological compliance.

[0045] This paper proposes a dynamic pruning optimization method based on reinforcement learning. This method aims to compress the search space and improve matching accuracy by gradually pruning low-confidence redundant matches through an intelligent agent. This method, based on the existing Proximal Policy Optimization (PPO) framework, integrates four aspects: state representation construction, action space definition, reward function design, and policy update. The overall process is described in Step 6.

[0046] Step 6: training the policy network and the value network based on the initial hard matching matrix to obtain a trained policy network; Step 6.1: defining a pruning action, and constructing a legal action space based on the initial hard matching matrix; The pruning action is to delete the matched query graph nodes and data graph nodes in the initial hard matching matrix, i.e., setting the confidence corresponding to the query graph nodes and data graph nodes in the initial hard matching matrix to 0, and the basic action constitutes a minimum pruning unit.

[0047] In order to manage and improve the efficiency of the strategy, the system divides the action space into a two-level structure: a node-level subspace and a global action space. The node-level subspace refers to: for each query node in the query graph The system independently maintains a prunable set consisting of candidate matching nodes. These sets represent the current candidate set that can be deleted. The global action space refers to: combining the node-level subspaces of all query nodes to form the entire set of pruning actions available to the system in the current state.

[0048] The legal action space includes a set of query graph nodes and data graph node pairs that can perform pruning actions, wherein the query graph nodes and data graph node pairs that can perform pruning actions have a confidence of 1 in the initial hard matching matrix. Step 6.2: initializing the parameters of the policy network and the parameters of the value network in the agent, and taking the initialized policy network as the current policy network and the initialized value network as the current value network. Specifically, two neural network models based on existing deep learning techniques are initialized, which are the policy network and the value network. In the subsequent training process, the policy network is used to output the probability distribution of each legal pruning action according to the current state, and the value network is used to estimate the expected return of the current state in the future, which is used to assist the optimization of the pruning strategy. The two networks are built by the PyTorch framework, adopt the existing three-layer fully connected structure, and use the Xavier uniform distribution to initialize all weight parameters.

[0049] The training system sets an experience pool to sequentially record trajectory samples generated during pruning, including the current state, pruning action, pruned state, and immediate reward. The experience pool uses a first-in, first-out mechanism and triggers a policy parameter optimization once the cumulative trajectory number reaches the set number. The parameter optimization is completed using the Adam optimizer combined with the proximal policy optimization algorithm (PPO).

[0050] Step 6.3: taking the initial hard matching matrix as the dynamic matching matrix, setting the initial pruning round number as the current pruning round number t. Step 6.4: Based on the legal action space and the dynamic matching matrix, set the dynamic mask vector; Specifically, for the pruning actions in the legal action space, the mask of the pruning action with a value of 0 in the dynamic matching matrix is set to 0. Among all the query graph nodes, the top 10% of the query graph nodes in the betweenness centrality are selected as key hub nodes. When the number of pruning actions corresponding to the key hub is 1, the mask of the pruning action is set to 0. The masks of all pruning actions form the dynamic mask vector. In the specific implementation process, the above content is described. Based on the legal action space, a Boolean mask vector mechanism is introduced to screen and constrain the pruning actions in the above action space, ensuring that the key structure is not mistakenly deleted and avoiding redundant pruning. The mask corresponds to the fixed action space one by one. Each bit flag corresponds to whether the pruning action is currently valid. If a pruning action should be shielded, the corresponding mask position is set to 0, indicating "not selectable". Otherwise, it is 1, indicating "selectable". The update of the mask is dynamically performed after each pruning execution. The dynamic mask rule includes: (1) Node importance constraint: According to the node betweenness centrality, the top 10% of query nodes are selected as key hub nodes. If there is only one candidate matching pair left for a key node, the candidate is marked as not deletable, i.e. the mask is invalid, to prevent the core of the graph structure from being damaged.

[0051] (2) Candidate state constraint: including two types of processing strategies: a. Empty candidate set shielding: if a query node currently has no remaining candidate matching, shield all deletion actions starting from the node; b. Repeat action shielding: if the pruning action corresponding to a candidate pair has been executed the same operation (such as continuous repeated pruning or marked after matching failure) within the previous K steps, temporarily shield the action to avoid strategy oscillation and redundant operation; In the subsequent steps, the mask vector will correspond to the original action probability output by the strategy network one by one. After element-wise multiplication and normalization, the probability distribution of the legal action is obtained.

[0052] Step 6.5: According to the dynamic matching matrix, construct the state vector of the tth round ; Step 6.5.1: Calculate the global embedding vector of the query graph , which is realized by the following formula: ; Where, represents the set of all nodes in the query graph , and represents the node output by the graph neural network GNN with the query graph The embedding vector of is a graph-level aggregation function that aggregates a set of node vectors into a single graph embedding vector; A graph neural network is used to encode the query graph and generate a global embedding vector of fixed dimension to capture the global features of the query graph, such as hub node distribution, community division and path density, to prevent local pruning from destroying the overall structural consistency. Moreover, this vector, as a static feature, remains unchanged throughout the pruning process and is not updated with the pruning status.

[0053] Query graph nodes corresponding to the t-1th round of pruning actions , extracting its first-order neighbor subgraph, encoding this local adjacency structure through a GNN, and generating an embedding vector to describe the local structural role of the node. This is specifically achieved through step 6.5.2. During the initial state construction phase, the query node corresponding to the first legal action (i.e., the action in the legal action space) is selected by default for processing. The legal actions selected here have been rule-filtered using a dynamic masking mechanism. During the subsequent pruning process, the query node currently being processed is determined by the query node in the pruned action sampled from the action probability distribution output by the previous round of the policy network. This node is used to construct the local subgraph embedding in the current state vector and serves as a reference for the current round of policy decisions.

[0054] Step 6.5.2: Calculate the local subgraph embedding vector , which is specifically achieved through the following formula: ; in, represents the query graph node corresponding to the t-1th round of pruning action, To query the graph with nodes The set of directly connected nodes, for A node in Indicates that The corresponding graph is used as input and the nodes output by the graph neural network GNN are The embedding vector of Indicates that the mean pooling operation is performed on all node embedding vectors; Step 6.5.3: Expand the dynamic matching matrix through sparse coding to obtain the eigenvector ; Specifically, the sparse coding method can be implemented based on existing compressed storage formats. The result can include an array of non-zero elements, an array of column indices, and an array of row pointers. To accommodate fixed input dimensions, the system presets a maximum vector length of L, padding any length with zeros and truncating any length beyond that.

[0055] Step 6.5.4: Calculate the structural violation thermal force vector H; Specifically, according to the dynamic matching matrix, all data graph nodes corresponding to the query graph node are determined, for each query graph node, the number of edges directly connected to the query graph node in the query graph is obtained, and a first value is obtained, for each data graph node corresponding to the query graph node, the number of edges directly connected to the data graph node in the data graph node is obtained, and a second value is obtained, and then a plurality of second values are obtained, the ratio of each second value to the first value is calculated, a plurality of edge existence rates are obtained, the average value of all edge existence rates is calculated, the average value is inverted and normalized, and a structure violation heat value is obtained , the structure violation heat values of all query graph nodes compose a structure violation heat vector; Wherein, the structure violation heat vector H is used to measure whether the candidate matching retained by each query node under the current pruning state meets the structural connectivity requirement. The system first identifies the candidate set of each node in the query graph, and analyzes whether these candidate nodes can maintain edge connection relationship with the candidate nodes of adjacent query nodes in the target graph.

[0056] Step 6.5.5: Concatenate the global embedding vector of the query graph , the local subgraph embedding vector , the feature vector and the structure violation heat vector H to obtain the state vector of the t-th round , which is specifically represented by the following formula: .

[0057] Wherein, the state vector will be dynamically updated with the pruning, and is used to drive the strategy network to make reasonable decisions. After the execution of each round of pruning action, the system reconstructs the state vector according to the updated dynamic matching matrix. The local subgraph embedding vector in the new state vector will be extracted and updated based on the query node in this round of action, realizing the dynamic evolution of state information and the connection of continuous pruning process.

[0058] It is worth noting that in the whole pruning process, the construction of each round of state vector is based on the graph state generated after the execution of the last round of pruning action ; The initial state is constructed by the default selected query node without pruning.

[0059] Step 6.6: Based on the state vector and the current strategy network, the current pruning action is obtained, the current pruning action is executed, and the corresponding position in the dynamic matching matrix is set to 0 to obtain a new dynamic matching matrix; Among them, based on the state vector and the current policy network to obtain the current pruning action ,include: The state vector of round t Input the current policy network to obtain the initial probability distribution of all pruning actions in the legal action space. The initial probability distribution is corrected by the dynamic mask vector. Specifically, the probability of the pruning action with a mask of 0 in the initial probability distribution is set to 0 to obtain the corrected probability distribution. The corrected probability distribution is normalized to obtain the target probability distribution. The target probability distribution is sampled by sampling to obtain the current pruning action. , current pruning action The corresponding node pair is denoted as , For the current pruning action The corresponding query graph node, For the current pruning action The corresponding data graph node; Step 6.7: Calculate the current pruning action Total Rewards ; Step 6.7.1: Calculate the current pruning action Matching accuracy reward , distinguishing correct matches from incorrect candidates through an asymmetric reward-penalty mechanism. Positive rewards are given for deleting incorrect matches, while high penalties are imposed for accidentally deleting correct matches. The reward size is adjusted based on the confidence level of the match to prioritize protecting true matches. This is achieved through the following formula: ; in, Represents a query graph node and data graph nodes In the global matching matrix The confidence level in Indicates an indicator function. The value is 1 when the condition in the brackets is met, otherwise it is 0. is the label matching matrix, Represents a query graph node and data graph nodes The true matching labels in the label matching matrix, Represents a query graph node and data graph nodes Match, Represents a query graph node and data graph nodes Does not match, is the penalty weight coefficient; Step 6.7.2: Calculate the current pruning action Structural consistency reward , strengthening critical path protection through an asymmetric reward and penalty mechanism. Rewards are given if the integrity of neighbor edge connections is improved after removing candidate matches, while penalties are imposed if local topology breaks are caused. The structural consistency reward is defined as the negative gradient of the violation heat, and the reward value increases as the violation decreases. It is implemented specifically through the following formula: ; in, Represents a query graph node The structural violation thermal value in round t-1, Represents a query graph node The structural violation thermal value in round t, Indicates the reward intensity, which is calculated using the following formula: ; in, is the basic weight coefficient, Represents a query graph node The betweenness centrality of represents the maximum value of the betweenness centrality of all nodes in the query graph; Step 6.7.3: Calculate the current pruning action Node importance reward , based on the betweenness centrality of the query node to measure its structural importance, to prevent the key structure from being mistakenly pruned and causing the overall topology to collapse. satisfy The betweenness centrality of exceeds the threshold , and the confidence of the pair in the global soft matching , the system will impose a negative penalty to suppress such pruning behavior, which is achieved through the following formula: ; in, is the node importance penalty coefficient, is the betweenness centrality threshold, is the global matching confidence threshold; Step 6.7.4: Calculate the current pruning action The sparsity reward , controls the number of candidate matches for a single query node to prevent the explosion of the search space caused by the accumulation of redundant matches. The system presets a unified upper threshold for candidate retention , for each query node, when the number of its current remaining candidates exceeds When , a linear penalty is imposed to encourage the strategy to prioritize deleting low-probability and redundant matching candidates, thereby compressing the search space and improving the efficiency of subsequent matching verification. This is achieved specifically through the following formula: ; wherein, denotes a sparsity penalty coefficient, denotes a query graph node the number of corresponding data graph nodes in the new dynamic matching matrix, and k is a preset upper threshold value; Step 6.6.5: Calculate the terminal reward of the current pruning action Step 6.7.5: Calculate the total reward of the current pruning action The reward is calculated based on the model-predicted matching quality, and the value is determined by the pruned dynamic matching matrix and the model-estimated global F1 score. By giving a high weight to the long-term goal, the model is guided to avoid deleting potential key matches too early in the early stage, and ultimately achieve global optimality. Specifically, it is realized by the following formula: ; wherein, denotes a weight coefficient of the terminal reward, denotes an F1 score, which comprehensively considers the recall and precision of the pruning result; Step 6.7.6: Calculate the total reward of the current pruning action Step 6.7.5: Calculate the total reward of the current pruning action Specifically, it is realized by the following formula: .

[0060] Step 6.8: Store ( , , , ) as a trajectory sample in the experience pool, increment the current pruning round t by one, and return to execute step 6.4 based on the new dynamic matching matrix until the pruning round reaches the preset threshold value, and all trajectory samples form a training set; Step 6.9: Based on the training set, the parameters of the current policy network and the parameters of the current value network are jointly updated by the PPO policy optimization algorithm, and the step 6.3 is returned to execute until the parameter update times reaches the preset number, or the loss value of the policy network of the two training is less than the preset threshold value, or the average value of the total reward of the policy network on the validation set for multiple times exceeds the preset threshold value, and the trained policy network is obtained.

[0061] Step 7: Obtain the user's new input query graph, execute steps 1-5 to obtain the initial hard matching matrix, generate a state vector based on the initial hard matching matrix, input the state vector into the trained policy network, generate pruning actions and execute pruning round by round until the entire pruning process is completed, and obtain the corresponding reserved candidate data graph nodes for each query graph node.

[0062] The application proposes a query graph subgraph matching algorithm based on a graph neural network, aiming to improve the expression ability of graph structure and control the aggregation range to cope with the challenges of over-smoothing and computational redundancy.

[0063] Firstly, the application proposes a query graph division algorithm based on betweenness centrality, which divides the query graph in a hierarchical and overlapping manner by selecting key hub nodes in the graph as the core. This division strategy can effectively preserve the global topology of the original query graph and split the query graph into multiple subgraphs of moderate size, avoiding the problems of over-smoothing effect and rising computational cost when directly performing multi-layer GNN aggregation on the whole graph, which is conducive to the extraction of subsequent local features.

[0064] Secondly, the application applies a graph neural network within each query subgraph to learn node representation, constructs node embedding by layer-by-layer aggregation of neighbor information, and generates a matching matrix between the subgraph and the data graph. In order to further improve the integration effect of different subgraph matching results, the application designs a multi-round bidirectional attention mechanism to fuse multiple local matching matrices. This mechanism uses node alignment and cross comparison between subgraphs to effectively explore the potential structural consistency between subgraphs, thereby improving the coherence and accuracy of the overall matching.

[0065] Finally, after constructing the global matching matrix, the application introduces a reinforcement learning strategy to optimize the pruning process. By modeling the matching path search as a Markov decision process and using the Proximal Policy Optimization (PPO) algorithm to train the pruning strategy network, the application realizes the dynamic selection of retaining or removing candidate matching items. This strategy not only improves the efficiency of the matching process, but also reduces the false matching rate while ensuring the integrity of key nodes.

[0066] The application has been verified on multiple public graph datasets, and the matching accuracy and F1-score are better than existing graph neural network subgraph matching methods. The overall algorithm has good scalability and can support efficient matching and structured analysis of complex graph structures.

[0067] The graph division module realizes structure-aware subgraph decomposition by identifying the center nodes in the query graph, effectively converting the query graph into multiple subgraphs with compact structure and concentrated semantics. This processing method significantly reduces the computational redundancy and representation ambiguity caused by whole-graph-level aggregation, improves the discrimination of node embedding, and enhances the matching accuracy and stability of the algorithm under complex graph structures. At the same time, the local processing after subgraph division greatly reduces the GNN computation and improves the overall running efficiency.

[0068] The bidirectional attention mechanism improves the structural consistency between subgraphs, making the edge connection in the matching result more reasonable and complete, and significantly reducing the structural mismatch rate. The multi-round attention fusion further aligns and integrates the local matching results, effectively alleviating the semantic fragmentation problem of subgraphs and improving the consistency and interpretability of global matching.

[0069] The reinforcement learning strategy autonomously learns the optimal pruning decision path through a policy optimization method, which can dynamically identify and eliminate untrustworthy candidate matching items. This module effectively reduces the search space and the false matching rate while preserving key structural matching, thereby improving the overall efficiency and robustness of the algorithm.

[0070] The above description is merely preferred embodiments of the present disclosure and a description of the principles of the technology used. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by any combination of the above technical features or equivalent features without deviating from the above inventive concept. For example, the above features can be replaced with similar functional technical features disclosed in the embodiments of the present disclosure (but not limited to) to form technical solutions.

Claims

1. A query graph subgraph matching method based on graph neural network, characterized in that: include: Step 1: Get the query graph input by the user and get the data graph corresponding to the query graph, which includes multiple nodes ,node The data graph includes multiple nodes v, and the nodes v are connected by edges; Step 2: Divide the query graph by betweenness centrality to obtain multiple query subgraphs; Step 3: For each query subgraph, calculate the local matching matrix between the query subgraph and the data graph , and then obtain multiple local matching matrices; Step 4: Based on the local matching matrix , calculate the global matching matrix ; Step 5: Based on the global matching matrix , generate the initial hard matching matrix; Step 6: Based on the initial hard matching matrix, train the policy network and value network to obtain the trained policy network; Step 7: Obtain the query graph newly input by the user, execute steps 1-5, obtain the initial hard matching matrix, generate a state vector based on the initial hard matching matrix, input the state vector into the trained policy network, generate pruning actions in rounds and execute pruning until the entire pruning process is completed, and obtain the retained candidate data graph node corresponding to each query graph node.

2. A query graph subgraph matching method based on graph neural network according to claim 1, characterized in that: Step 2 specifically includes: For each node in the query graph , computing nodes Betweenness centrality , which is specifically achieved through the following formula: ; in, Represents a node in the query graph s To Node t The number of paths between which the path length is the target path length, and the target path length is the number of paths between which the path length is the target path length. s To Node t The shortest path length between Indicates that in a path whose path length is the target path length, the path passes through the node The number of paths; Among the betweenness centralities of all nodes, obtain the node corresponding to the largest betweenness centrality, use the node as the core node, obtain multiple nodes directly connected to the core node through edges, and form a query subgraph with the nodes directly connected to the core node through edges, the core node, and the edges connecting the nodes. Delete the nodes of the query subgraph from all the nodes in the query graph, and return the node corresponding to the largest betweenness centrality among all the remaining nodes, thereby obtaining multiple query subgraphs.

3. The query graph subgraph matching method based on graph neural network according to claim 1 is characterized in that: Step 3 specifically includes: Step 3.1: Query subgraph Each node u and each node of the data graph v Input into the same GNN respectively to get the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v ; Step 3.2: Based on the query subgraph node u Embedding vector of h u and data graph nodes v Embedding vector of h v , calculate the local matching matrix , and then obtain multiple local matching matrices; Step 3.2.1: Calculate each node in the query subgraph u And each node in the data graph v The similarity between , which is specifically achieved through the following formula: ; in, represents vector concatenation, W is a learnable parameter; Step 3.2.2: Based on similarity , computing nodes u and nodes v The matching probability between , which is specifically achieved through the following formula: ; in, Represents a collection of data graph nodes, Represents a query subgraph node u and data graph nodes similarity; Local matching matrix of the matching probability between each node in the query subgraph and each node in the data graph , and then obtain multiple local matching matrices.

4. The query graph subgraph subgraph matching method based on graph neural network according to claim 1, characterized in that: Step 4 specifically includes: Step 4.1: Compute the query subgraph S i and query subgraph S j The comprehensive similarity between ; Step 4.2: Based on comprehensive similarity , calculate the query subgraph S i The attention weight and query subgraph S j The attention weight , which is specifically achieved through the following formula: ; ; in, Query subgraph S i and query subgraph S k The comprehensive similarity between Query subgraph S j and query subgraph S k The comprehensive similarity between Step 4.3: Perform multiple iterations on the attention weight of the query subgraph and the embedding vector of the query subgraph to obtain the final embedding vector and the final attention weight of the query subgraph; Step 4.4: Final attention weight and local matching matrix based on query subgraph , calculate the global matching matrix ; Specifically, based on the final attention weight of the query subgraph, the fusion coefficient is calculated , which is specifically achieved through the following formula: ; ; Among them, Z is the intermediate variable, K is the total number of query subgraphs, Query subgraph S i The final attention weight, Query subgraph S j Final attention weights; According to the fusion coefficient and the local matching matrix , calculate the global matching matrix , where the global matching matrix Contains multiple confidence levels, which are implemented through the following formula: 。 5. The query graph subgraph subgraph matching method based on graph neural network according to claim 4 is characterized in that: Step 4.1 specifically includes: Step 4.1.1: Get the query subgraph S i Node set , ,in, m i Represents a query subgraph S i The total number of nodes, Represents a query subgraph S i The first node in Query subgraph S i The m i nodes; get the query subgraph S j Node set , ,in, m j Represents a query subgraph S j The total number of nodes, Represents a query subgraph S j The first node in Query subgraph S j The m j nodes; Step 4.1.2: Compute the query subgraph S i Nodes and query subgraphs S j The similarity between nodes is specifically achieved through the following formula: ; in, For node sets The nodes in for The embedding vector of For node sets The nodes in for The embedding vector of T represents transpose, Representation node and nodes similarity; Compute query subgraph S i Each node and query subgraph S j The similarity between each node is obtained to obtain the similarity matrix; Step 4.1.3: Query subgraph S i For each node in the similarity matrix, get the node Corresponding to multiple similarities, among the multiple similarities, the similarity with the largest value is obtained as the first similarity, and then each node Get a first similarity, calculate the average of all similarities, and get the node alignment score , specifically expressed by the following formula: ; Step 4.1.4: Based on node alignment score Calculate comprehensive similarity , which is specifically achieved through the following formula: ; in, Represents a query subgraph S i Embedding vector and query subgraph of S j The similarity of the embedding vectors of β is a hyperparameter.

6. The query graph subgraph subgraph matching method based on graph neural network according to claim 4 is characterized in that: Step 4.3 specifically includes: Step 4.3.1: Set the initial number of iterations = 0, and use the embedding vectors of all nodes in the query subgraph as = 0, the embedding vector of the query subgraph is used as the attention weight of the query subgraph =0 when the attention weight of the query subgraph is Step 4.3.2: Update the embedding vector of the query subgraph based on the attention weights of all query subgraphs. This is achieved by the following formula: ; in, l represents the number of iterations, Indicates the +1 iteration to query the subgraph S i The embedding vector of For the Iteration , Indicates the Iteration query subgraph S j Embedding vector of Step 4.3.3: Add one to the current number of iterations to determine whether the embedding vector of the query subgraph converges or whether the number of iterations reaches the preset threshold. If the embedding vector of the query subgraph converges or the number of iterations reaches the preset threshold, the first The embedding vector of the query subgraph in the +1 iteration is used as the final embedding vector of the query subgraph, and the The attention weight of the query subgraph in the iteration is used as the final attention weight of the query subgraph. If the embedding vector of the query subgraph does not converge and the number of iterations does not reach the preset threshold, execute steps 4.1, 4.2, 4.3.2 and 4.3.

3.

7. The query graph subgraph subgraph matching method based on graph neural network according to claim 1 is characterized in that: Step 5 specifically includes: Step 5.1: Based on the preset threshold Global matching matrix To process, specifically, the global matching matrix Greater than or equal to the preset threshold The confidence level is set to 1, and the global matching matrix Less than the preset threshold The confidence of is set to 0, and the first hard matching matrix is ​​obtained. ; Step 5.2: Based on the first hard matching matrix , calculate the target threshold , which is specifically achieved through the following formula: ; in, For all node pairs Seek hope, represents the first hard matching matrix Middle Rank v The confidence level of the column, express The true matching label, To pass the cross entropy loss function, and The calculated loss value; Step 5.3: Based on target threshold , calculation dynamics The value is realized by the following formula: ; in, represents the maximum value of the betweenness centrality of all nodes in the query graph; In the global matching matrix , get the node All corresponding confidence levels, get the previous one among all confidence levels confidence, and obtain the previous The confidence level corresponds to the data graph node, and the node Before The confidence levels of the data graph nodes corresponding to the first set are used to form a first set, and then the first set corresponding to each query graph node is obtained; Based on the first set corresponding to each query graph node, a second hard matching matrix is ​​generated. Specifically, the values ​​of the corresponding positions of the data graph nodes corresponding to the query graph nodes in the first set in the matrix are set to 1, and the values ​​of the other positions are set to 0, thereby obtaining the second hard matching matrix. For the case where a data graph node corresponds to multiple query graph nodes in the second hard matching matrix, the data graph node is regarded as a conflict node, and for each conflict node , get all the corresponding query graph nodes, and use all the corresponding query graph nodes as candidate nodes. All candidate nodes of each conflicting node form a conflict set ; Compute conflict sets Each candidate node in Comprehensive scoring indicators , which is specifically achieved through the following formula: ; in, represents the global matching matrix Middle Rank The confidence of the column, that is, the candidate node Conflict Node Confidence of the match; In the conflict set In the query graph, all candidate nodes have a comprehensive scoring index corresponding to them, and the candidate node with the largest comprehensive scoring index is obtained, which is used as the query graph node that is the only match for the conflicting node. Thus, the query graph node that uniquely matches each conflicting node is determined, and an initial hard matching matrix is ​​generated. Specifically, the values ​​of the corresponding positions of the conflicting node and the uniquely matching query graph node in the matrix are set to 1, and the values ​​of other positions are set to 0 to obtain the initial hard matching matrix.

8. The query graph subgraph subgraph matching method based on graph neural network according to claim 1 is characterized in that: Step 6 specifically includes: Step 6.1: Define pruning actions and construct a legal action space based on the initial hard matching matrix; The pruning action is to delete the matched query graph nodes and data graph nodes in the initial hard matching matrix, that is, to set the confidences corresponding to the query graph nodes and data graph nodes in the initial hard matching matrix to 0; The legal action space includes a set of query graph node and data graph node pairs that can perform pruning actions, wherein the confidence of the query graph node and data graph node pairs that can perform pruning actions is 1 in the initial hard matching matrix; Step 6.2: Initialize the parameters of the policy network and the value network in the agent, and use the initialized policy network as the current policy network and the initialized value network as the current value network; Step 6.3: Use the initial hard matching matrix as the dynamic matching matrix, set the initial pruning round number, and use the initial pruning round number as the current pruning round number t; Step 6.4: Set the dynamic mask vector based on the legal action space and the dynamic matching matrix; Specifically, for pruning actions in the legal action space, the masks of pruning actions with a value of 0 in the dynamic matching matrix are set to 0; among all query graph nodes, the query graph nodes with the top 10% betweenness centrality are regarded as key hub nodes. When the number of pruning actions corresponding to the key hub is 1, the mask of the pruning action is set to 0. The masks of all pruning actions form a dynamic mask vector; Step 6.5: Construct the state vector of round t based on the dynamic matching matrix ; Step 6.6: Based on the state vector and the current policy network to obtain the current pruning action , execute the current pruning action , and set the corresponding position in the dynamic matching matrix to 0 to obtain a new dynamic matching matrix; Among them, based on the state vector and the current policy network to obtain the current pruning action ,include: The state vector of round t Input the current policy network to obtain the initial probability distribution of all pruning actions in the legal action space. The initial probability distribution is corrected by the dynamic mask vector. Specifically, the probability of the pruning action with a mask of 0 in the initial probability distribution is set to 0 to obtain the corrected probability distribution. The corrected probability distribution is normalized to obtain the target probability distribution. The target probability distribution is sampled by sampling to obtain the current pruning action. , current pruning action The corresponding node pair is denoted as , For the current pruning action The corresponding query graph node, For the current pruning action The corresponding data graph node; Step 6.7: Calculate the current pruning action Total Rewards ; Step 6.8: , , , ) is stored as a trajectory sample in the experience pool, the current pruning round number t is increased by one, and step 6.4 is executed again based on the new dynamic matching matrix until the pruning round number reaches the preset threshold. All trajectory samples constitute the training set; Step 6.9: Based on the training set, use the PPO policy optimization algorithm to jointly update the parameters of the current policy network and the current value network. Return to step 6.3 and continue until the number of parameter updates reaches the preset number, or the loss value of the policy network after two trainings is less than the preset threshold, or the average of the total rewards of the policy network on the validation set exceeds the preset threshold. The trained policy network is obtained.

9. The query graph subgraph subgraph matching method based on graph neural network according to claim 8, characterized in that: Step 6.5 specifically includes: Step 6.5.1: Compute the global embedding vector of the query graph , which is specifically achieved through the following formula: ; in, Representing a query graph The set of all nodes in Indicates that the query graph As input, the nodes output by the graph neural network GNN The embedding vector of It is a graph-level aggregation function; Step 6.5.2: Calculate the local subgraph embedding vector , which is specifically achieved through the following formula: ; in, represents the query graph node corresponding to the t-1th round of pruning action, To query the graph with nodes The set of directly connected nodes, for A node in Indicates that The corresponding graph is used as input and the nodes output by the graph neural network GNN are The embedding vector of Indicates that the mean pooling operation is performed on all node embedding vectors; Step 6.5.3: Expand the dynamic matching matrix through sparse coding to obtain the eigenvector ; Step 6.5.4: Calculate the structural violation thermal force vector H; Specifically, according to the dynamic matching matrix, all data graph nodes corresponding to the query graph node are determined. For each query graph node, the number of edges directly connected to the query graph node is obtained in the query graph to obtain a first value. For each data graph node corresponding to the query graph node, the number of edges directly connected to the data graph node is obtained in the data graph node to obtain a second value, and then multiple second values ​​are obtained. The ratio of each second value to the first value is calculated to obtain multiple edge existence rates. The average value of all edge existence rates is calculated, the average value is inverted and normalized, and the structural violation thermal value is obtained. , the structural violation thermal values ​​of all query graph nodes Composition structure violation thermal vector; Step 6.5.5: Global embedding vector of the query graph , local subgraph embedding vector , eigenvector Combined with the structural violation thermal vector H, the state vector of round t is obtained , specifically expressed by the following formula: 。 10. The query graph subgraph subgraph matching method based on graph neural network according to claim 8, characterized in that: Step 6.7 specifically includes: Step 6.7.1: Calculate the current pruning action Matching accuracy reward , which is specifically achieved through the following formula: ; in, Represents a query graph node and data graph nodes In the global matching matrix The confidence level in Indicates an indicator function. The value is 1 when the condition in the brackets is met, otherwise it is 0. is the label matching matrix, Represents a query graph node and data graph nodes The true matching labels in the label matching matrix, Represents a query graph node and data graph nodes Match, Represents a query graph node and data graph nodes Does not match, is the penalty weight coefficient; Step 6.7.2: Calculate the current pruning action Structural consistency reward , which is specifically achieved through the following formula: ; in, Represents a query graph node The structural violation thermal value in round t-1, Represents a query graph node The structural violation thermal value in round t, Indicates the reward intensity, which is calculated using the following formula: ; in, is the basic weight coefficient, Represents a query graph node The betweenness centrality of represents the maximum value of the betweenness centrality of all nodes in the query graph; Step 6.7.3: Calculate the current pruning action Node importance reward , which is specifically achieved through the following formula: ; in, is the node importance penalty coefficient, is the betweenness centrality threshold, is the global matching confidence threshold; Step 6.7.4: Calculate the current pruning action The sparsity reward , which is specifically achieved through the following formula: ; in, represents the sparsity penalty coefficient, Represents a query graph node The number of corresponding data graph nodes in the new dynamic matching matrix, k is the preset upper threshold; Step 6.6.5: Calculate the current pruning action End-game rewards , which is specifically achieved through the following formula: ; in, Indicates the weight coefficient of the final reward, Represents the F1 score, which comprehensively considers the recall and precision of the pruning results; Step 6.7.6: Calculate the current pruning action Total Rewards , which is specifically achieved through the following formula: 。

Citation Information

Cited By

  • GNN-based multi-stage structure optimization sub-graph matching method

    CN121434800A

  • Real-time APT attack dynamic detection method based on traceability graph matching

    CN121603307A