Sub-graph matching search plan generation method and device, storage medium and computer program product

Through operation-based search paradigms and graph neural networks, a fine-grained search plan is generated, which solves the problem of matching order dependence heuristics and extended operation granularity coarse in existing subgraph matching algorithms, and improves the efficiency and accuracy of subgraph matching.

CN120470155APending Publication Date: 2025-08-12HUNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510526708.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-25
Publication Date
2025-08-12

AI Technical Summary

Technical Problem

Existing subgraph matching algorithms rely on heuristic strategies when generating matching orders, which are difficult to adapt to different query requirements, and the expansion operation is coarse, affecting efficiency.

Method used

Adopting an operation-based search paradigm, using graph neural network to capture the structural features of data graphs and query graphs, generate fine-grained search plans through reinforcement learning, independently process generation and expansion operations, and reduce search space and operation times.

Benefits of technology

It improves the efficiency of sub-graph matching, reduces search costs and operation times, and provides more accurate matching results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120470155A_ABST
    Figure CN120470155A_ABST
Patent Text Reader

Abstract

The invention provides a subgraph matching search plan generation method and device, a storage medium and a computer program product. The method comprises the steps of obtaining an initialization feature of each query vertex; capturing a representation of each query vertex using a graph neural network; identifying query vertexes in the action space in the activation process; calculating the probability that each query vertex is selected to perform generation operation, and adding the generation operation of the query vertex with the highest probability into the search plan and the extended candidate pool; evaluating whether each query vertex in the extension candidate pool should perform an extension operation; removing query vertexes needing to execute expansion operation from the expansion candidate pool and adding the query vertexes into the search plan; under the condition that all the query vertexes in the query graph are subjected to the generation operation, expansion operation of the remaining query vertexes in the expansion candidate pool is automatically added into the search plan. According to the method, the sub-graph matching efficiency is improved, and the search cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of graph data search technology, and in particular to a subgraph matching search method, device, storage medium, and computer program product. Background Art

[0002] In the field of graph data analysis, subgraph matching has long been a hot topic of research. The goal of subgraph matching algorithms is to find subgraphs in a data graph that have the same structure as the query graph. This problem has applications in various fields, including social network analysis, bioinformatics, and knowledge graphs. The following are the main research advances and current status of subgraph matching technology:

[0003] Traditional subgraph matching algorithms: Traditional subgraph matching algorithms primarily consist of three components: generating a candidate vertex set, generating a matching order, and enumeration. These algorithms typically rely on heuristic strategies to generate the matching order, a key factor in optimizing performance. However, these algorithms may generate different matching orders for specific query graphs, making it difficult to determine the most efficient order. For example, the Ullmann algorithm solves the subgraph matching problem through backtracking, but its efficiency decreases dramatically as the graph size increases.

[0004] Index / auxiliary data structure-based methods: To improve efficiency, various index-based methods have been proposed in the prior art, such as using data structures like B-trees and hash tables to reduce the candidate set and accelerate the pruning process. These methods improve efficiency by reducing the complete candidate set and accelerating pruning during the enumeration process.

[0005] Graph partitioning-based methods: Divide the large graph into small tiles and then perform subgraph matching on each tile. This method can reduce the search space, but there may be challenges in handling the boundaries between tiles.

[0006] Machine learning-based methods: With the development of machine learning technology, machine learning has begun to be used to improve subgraph matching. For example, the RLQVO algorithm uses reinforcement learning to determine the matching order, but it still relies on traditional expansion-level subgraph matching, resulting in a coarse search granularity.

[0007] Methods based on operation-level search: The new SP algorithm first introduced an operation-level search process, but its search plan generation still relies on heuristic strategies. These strategies often ignore the structural characteristics of the query graph and data graph when generating matching orders.

[0008] Deep learning-based methods use graph neural networks to decompose the graph and then perform matching in the embedding space, but these methods can usually only determine the existence of the query graph in the data graph without providing an exact solution.

[0009] In summary, although subgraph matching has made some progress in the existing technology, it still has two major shortcomings: first, the matching order generation is usually heuristic and difficult to adapt to different query requirements; second, the granularity of each expansion operation is coarse, which may affect performance.

[0010] Therefore, there is an urgent need to provide a subgraph matching search plan generation method, device, storage medium and computer program product to adapt to different query requirements and / or improve operation granularity.

[0011] Application Contents

[0012] Embodiments of the present application provide a subgraph matching search plan generation method, device, storage medium, and computer program product.

[0013] In a first aspect, an embodiment of the present application provides a method for generating a subgraph matching search plan, the method comprising:

[0014] Initialize the features of each query vertex of the query graph using a heuristic strategy to obtain the initialized features of each query vertex;

[0015] Utilize graph neural networks to capture the representation of each query vertex;

[0016] identifying a query vertex in an action space through an activation process, wherein the action space consists of query vertices that have not completed a generate operation themselves but have at least one neighbor that has completed an expand operation;

[0017] Using a multilayer perceptron to calculate the probability of each query vertex being selected for a generation operation based on representations of the query vertices in the action space, adding the generation operation of the query vertex with the highest probability to a search plan, and adding the query vertex with the highest probability to an expanded candidate pool;

[0018] evaluating each query vertex in the expansion candidate pool using a multilayer perceptron to evaluate whether an expansion operation should be performed on each query vertex;

[0019] Removing query vertices that require an expansion operation from the expansion candidate pool and adding them to the search plan, and retaining query vertices that do not require an expansion operation in the expansion candidate pool;

[0020] Determining whether all query vertices in the query graph have undergone a generation operation; and

[0021] In a case where all query vertices in the query graph have undergone a generation operation, the expansion operations of the remaining query vertices in the expansion candidate pool are automatically added to the search plan.

[0022] In one embodiment, when there is a query vertex in the query graph that has not undergone a generation operation, the process returns to the step of “identifying the query vertex in the action space through an activation process” and continues to execute.

[0023] In one embodiment, the “initializing the features of each query vertex of the query graph using a heuristic strategy” further includes:

[0024] The number of vertices in the statistical graph that have at least the same degree and matching label as each query vertex is calculated using a first feature metric, thereby estimating the size of the candidate set for each query vertex, wherein the first feature metric is defined as follows:

[0025] f1(u)=|{v∈G|d(u) <d(v)&&L(u)=L(v)}|.

[0026] Where u is a query vertex in the query graph, G is the set of all vertices in the data graph, v belongs to G means traversing the vertices in the data graph, d(u) and d(v) represent the degrees of query vertex u and vertex v respectively, L(u) and L(v) represent the labels of query vertex u and vertex v respectively;

[0027] The second characteristic metric is used to calculate the number of neighbors of the current query vertex that have completed the expansion operation, wherein the second characteristic metric is defined as follows:

[0028] f2(u)=|{u′∈N q (u)|exp(u′)in search plan}|.

[0029] Where u is the current query vertex, u' represents the neighbors of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, and exp(u')in search plan represents whether the neighbor u' has been expanded in the search plan;

[0030] A third characteristic metric is used to quantify the number of neighbors of the current query vertex waiting for the generate operation, wherein the third characteristic metric is defined as follows:

[0031] f3(u)=|{u′∈N q (u)|gen(u′)not in search plan}|.

[0032] Where u is the current query vertex, u' represents the neighbors of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, gen(u')in search plan indicates whether the candidate generation operation of neighbor u' is already in the search plan, and the symbol "|…|" represents the number of neighbors that meet the conditions; and

[0033] The fourth feature metric is used to calculate the number of vertices in the query graph that have the same label as the current query vertex and have undergone local candidate expansion, wherein the fourth feature metric is defined as follows:

[0034]

[0035] Wherein, u is the current query vertex, u' represents any query vertex in the query graph, V(q) is the set of all query vertices in the query graph q, L(u') and L(u) represent the labels of the query vertex u' and the current query vertex u, respectively, and exp(u')in search plan indicates whether the query vertex u' has been expanded in the search plan.

[0036] In one embodiment, the “initializing the features of each query vertex of the query graph using a heuristic strategy” further includes:

[0037] The fifth characteristic metric is used to calculate the number of query vertices that have completed the generation operation, where the fifth characteristic metric is defined as follows:

[0038] f5(u)=|{u∈V(q)gen(u)in search plan}

[0039] Where u is a query vertex in the query graph, V(q) represents the set of all query vertices in the query graph q, and gen(u)in search plan indicates whether the candidate generation operation for query vertex u has been included in the search plan;

[0040] The sixth characteristic metric is used to calculate the number of query vertices that have completed the expansion operation, where the sixth characteristic metric is defined as follows:

[0041] f6(u)=|{u∈V(q)|exp(u)in search plan}|

[0042] Wherein, u is a query vertex in the query graph, V(q) represents the set of all query vertices of the query graph q, and exp(u)in search plan represents whether the query vertex u has been expanded in the search plan.

[0043] In one embodiment, “capturing the representation of each query vertex using the graph neural network” includes: using a graph convolutional network to convert the feature vector of each query vertex into a representation through a message passing algorithm on the graph, allowing each query vertex to learn a representation that includes its local neighborhood context information, wherein the mathematical expression for representing the representation of the query graph using the graph convolutional network is as follows:

[0044]

[0045] Among them, H (l) is the query vertex representation matrix of the lth layer; is the enhanced adjacency matrix A of the graph, by adding self-connections I N The identity matrix is expanded; yes The diagonal query vertex degree matrix, W (l) is the weight matrix of the lth layer, σ(·) represents the nonlinear activation function, H (l+1) is the query vertex representation matrix of the l+1th layer.

[0046] In one embodiment, a two-layer multilayer perceptron is used to calculate the probability of each query vertex being selected for the generation operation in the action space. The probability is calculated as follows:

[0047] P t (u i )=MLP(H t (u i )),

[0048] Among them, u i is the query vertex, u i ∈AS,H t (u i ) represents the query vertex u i The initial representation at t iteration steps,

[0049] The “adding the query vertex with the highest probability to the search plan and the expanded candidate pool” includes:

[0050] All the calculated probability values are normalized by applying the softmax function. After normalization, the query vertex with the largest probability value is added to the search plan and the expanded candidate words. The calculation formula for selecting the query vertex with the largest probability value is as follows:

[0051]

[0052] Among them, u * Represents the query vertex with the largest probability value.

[0053] In one embodiment, an expansion classifier is used to evaluate whether an expansion operation should be performed on each query vertex in the expansion classification pool:

[0054]

[0055] Among them, E(u j ) represents the selection of query vertex u j The decision to perform the expansion operation, Classifier(·) is the expansion classifier function, which is used to evaluate the query vertex u j Whether it should be expanded.

[0056] In a second aspect, the present application further provides a subgraph matching search plan generation device, the subgraph matching search plan generation device comprising:

[0057] a memory configured to store computer-executable instructions;

[0058] A processor is configured to run the computer-executable instructions stored in the memory to implement the above-mentioned subgraph matching search plan generation method.

[0059] In a third aspect, the present application further provides a storage medium storing computer-executable instructions, which, when executed by a processing unit, implement the above-mentioned subgraph matching search plan generation method.

[0060] In a fourth aspect, the present application further provides a computer program product, which includes computer program instructions, and when the computer program instructions are executed by a processing unit, the above-mentioned subgraph matching search plan generation method is implemented.

[0061] Compared with the prior art, the subgraph matching search plan generation method, device, storage medium and computer program product provided by the embodiments of the present application propose a new operation-level search paradigm, which regards the generation (gen) operation and the expansion (exp) operation as independent computing units, eliminating the need for the generation operation and the expansion operation to occur at the same time. Compared with the traditional expansion-level search, this can reduce the search space and the number of generation operations. Secondly, the use of reinforcement learning strategies to generate operation-based search plans is an innovative attempt to guide the search process more effectively. Furthermore, by using graph neural networks, it is possible to capture the structural features in the data graph and the query graph, provide more accurate context information for the generation and expansion operations, improve the efficiency of subgraph matching, and reduce the search cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present application. Those skilled in the art can also derive other drawings based on these drawings without inventive work, among which:

[0063] Figure 1 It is a query graph and a data graph of an example of an embodiment of the present application;

[0064] Figure 2 is based on Figure 1 Example query graphs and data graphs, schematic diagrams of search plans generated using prior art methods and the subgraph matching search plan generation method provided in embodiments of this application;

[0065] Figure 3 This is a functional module diagram of an apparatus for executing a subgraph matching search plan generation method provided in one embodiment of the present application;

[0066] Figure 4 1 is a flow chart of a method for generating a subgraph matching search plan provided in one embodiment of the present application;

[0067] Figure 5 is a schematic diagram of an example of a method for describing a subgraph matching search plan in an embodiment of the present application;

[0068] Figure 6 It is a schematic diagram of the hardware structure of a subgraph matching search plan generation device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0069] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0070] With the rapid development of the Internet, graph-structured data is becoming increasingly important in various fields, especially in the fields of recommendation systems, network security, and computational chemistry. As a core problem in graph analysis, the efficiency and accuracy of subgraph matching are crucial for discovering patterns and structures in data graphs. However, existing subgraph matching methods have two major shortcomings: first, the matching order generation is usually heuristic and difficult to adapt to different query requirements; second, the granularity of each expansion operation is coarse, which may affect performance. In order to solve these problems, the present invention proposes a subgraph matching search plan generation method, device, storage medium and computer program product, which adopts an operation-based fine-grained search plan and generates a search plan through a reinforcement learning strategy to improve the efficiency of subgraph matching.

[0071] The following reference Figure 1 and Figure 2 Introduce the concepts of terms used in the embodiments of this application, Figure 1 Part (a) of is an example query graph. Figure 1 Part (b) is a data graph of an example. Figure 2 Part (a) is an example of a search plan generated by the prior art, Figure 2 Part (b) is a search plan generated by an implementation method of the present application.

[0072] Graph: A graph is a triplet G = (V, E, L). V is the set of vertices and E is the set of edges. L is a labeling function that assigns labels to each vertex and edge. For simplicity, L(u) and L(u, v) are used to represent the labels of vertex u and edge (u, v) respectively. The sets of different vertex (edge) labels are denoted as L(V) and L(E). G (V) represents the neighbor set of v in G, and degr(v) represents the corresponding average degree. For the convenience of expression, V can also be used G 、E G 、L G Represent the vertex set, edge set and label function of G respectively.

[0073] Subgraph isomorphism: Given two graphs q = (V, E, L) and G = (V′, E′, L′), where q is the query graph and G is the data graph, a subgraph isomorphism is an injective function f from V to V′ that satisfies the following conditions: (1) (2)

[0074] Matching order Φ: Given a query graph Q, the matching order Φ is the sequence of all vertices in the query graph: u1→u2→…→u k (where k = |V(Q)|, the number of vertices in the query graph). For example, Figure 1 The query graph in part (a) of Figure 1The matching order Φ searched on the data graph G in part (b) is u1→u2→u3→u4→u5.

[0075] Complete candidate vertex set C(u): Given a query graph q and a data graph G, for each vertex u∈V(q) in the query graph, the complete candidate vertex set C(u) includes all data vertices v∈V(G) that can match u in the data graph. Although different subgraph matching algorithms may calculate C(u) differently, the embodiments of this application do not have specific requirements for the calculation method of candidate vertices. Therefore, the embodiments of this application do not involve the method for generating the complete candidate vertex set.

[0076] Left / right neighbor: If vertex u i is vertex u j neighbors, and u i In the matching order, the j Before (after), then u i is u j The left (right) neighbor of . In the embodiment of the present application, LN(u i ) represents u i The left neighbor set, RN(u i ) represents u i The set of right neighbors of . For example, in Figure 2 In the matching order Φ=u1→u2→u3→u4→u5 of the query graph in (a), LN(u3)=u1,u2, because u1 and u2 are both before u3 in the matching order and are connected to u3 by an edge. Similarly, in the embodiment of the present application, if u i is the query graph q in u j neighbors, and exp(i)<exp(j)(exp(i)>exp(j)), then u i is u j The left (right) neighbor of .

[0077] Mapping M: M[u] is the data vertex mapped to the query vertex u. M is a partial match from the query graph q to the data graph G. In the embodiment of the present application, when the set M contains the solutions of all query vertices, M is defined as a final match.

[0078] Local candidate LC(u): Local candidate generation can be formalized as Where M[u′] is the data vertex mapped to u′. For example, in Figure 1In part (a) of

[15] , LC(u3) = {v′∈C(u3) / v′∈NG(v5)&&v′∈NG(v4)}, since LN(u3) = {u1,u2}, M[u1] = v5, and M[u2] = v4. This means that v′ must be a vertex in u3’s candidate vertex set C(u3), and for all left neighbors u1 and u2 of u3, there must be an edge between v′ and the data vertices v5 and v4 they map to in the data graph G.

[0079] Generation operation gen: The generation operation gen is responsible for calculating the local candidate set for each query vertex u.

[0080] Extension operation exp: retrieves and expands the local candidate set of the query vertex u from the candidate pool.

[0081] Compared with conventional subgraph matching algorithms in the prior art, the embodiment of the present application adopts an operation-based search method. Figure 2 As shown, in the embodiment of the present application, the generation operation gen is responsible for calculating the local candidate set for each query vertex u. If the local candidate set is found to be empty, it indicates the termination of the current subgraph matching search. For example, Figure 2 Parts (a) and (b) of show the case where the search is terminated due to the lack of a local candidate set for u5 in the gen(u5) operation (i.e., the generation operation of query vertex u5). Figure 3 As shown, the expansion operation exp is to retrieve and expand the local candidate set of the query vertex u from the candidate pool. According to the embodiment of the present application, the candidate expansion and expansion operation of the query vertex u at the time of generation plays a crucial role. Immediate expansion after generation imposes stricter topological constraints on the local candidates of u's right neighbors. For example, Figure 2 In part (b), the local candidate set LC(u3) = v7, v8 of u3 is based on the rule However, if the search plan executes exp(u2) after gen(u3), then the generation rule for gen(u3) becomes This results in the local candidate set for u3 being expanded to LC(u3) = {v7, v8, v9}. Therefore, generation is usually prioritized over candidate expansion.

[0082] Delaying expansion can sometimes reduce search space redundancy and local candidate generation. Figure 2As shown in part (b) of , traditional enumeration methods usually put the single-degree vertex u5 at the end of the search plan. This is to avoid the Cartesian product phenomenon in the search space due to the exp operation on u5. In essence, this method moves both gen(u5) and exp(u5) to the end. However, in this particular case, the result of gen(u5) is an empty set, which can speed up the determination of the search process. By putting gen(u5) at the end, the algorithm misses the opportunity to terminate the search early. Therefore, the operation-based search method of the embodiment of the present application solves this problem and eliminates the requirement that the exp operation must follow the gen operation. Therefore, gen(u5) can be performed directly without having to worry about the exp(u5) operation causing a Cartesian product in the search space. As shown Figure 2 As shown, compared with the method in the prior art, the subgraph matching search plan generation method provided by the embodiment of the present application reduces the search space and the number of local candidate generation times by 80% and 44% respectively.

[0083] See also Figure 3 As shown, Figure 3 This is a diagram of software modules for an apparatus that executes the subgraph matching search plan generation method in an embodiment of the present application. In this embodiment, the software modules for executing the subgraph matching search plan generation method include a graph feature extraction module 310 , a generation module 320 , an expansion module 330 , and a reward and learning module 340 .

[0084] See also Figure 4 and Figure 5 ,in Figure 4 Schematic diagram of the flow of the subgraph matching search plan generation method provided in the embodiment of this application, Figure 5 Schematic diagram illustrating the process of subgraph matching search plan generation using examples.

[0085] In operation 401 , the graph feature module 310 initializes the features of each query vertex of the query graph using a heuristic strategy to obtain the initialized features of each query vertex.

[0086] In operation 402 , the graph feature module 310 captures a representation of each query vertex using a graph neural network.

[0087] See Figure 5 As shown in part (a) "Graph Feature Extraction," for an input query graph 500, a matching subgraph (or cover set) must be obtained in the data graph 501. The graph feature module 310 first initializes the features of each query vertex to obtain initialization features 502, and then uses a graph neural network (CNN layer) 503 to capture the representation (i.e., node representation) 504 of each query vertex.

[0088] In operation 403 , the generation module 320 identifies a query vertex in an action space through an activation process, wherein the action space consists of vertices that have not completed the generation operation themselves but have at least one neighbor that has completed the expansion operation.

[0089] In operation 404, the generation module 320 uses a multilayer perceptron to calculate the probability of each query vertex being selected for the generation operation based on the representation of the query vertex in the action space, adds the generation operation of the query vertex with the highest probability to the search plan, and adds the query vertex to the expansion candidate pool.

[0090] See Figure 5 As shown in part (b): "Generate", the Generate module 320 identifies query vertices u2, u3, and u4 in the action space with labels B, C, and D, respectively, during activation. The Multilayer Perceptron (i.e., Probabilistic MLP 505) calculates the probability of each of the query vertices u3, u4, and u5 being selected for the Generate operation based on the representations 504 of the query vertices u3, u4, and u5. Figure 5 In the figure, for the sake of intuitiveness, a bar chart is used to represent the probability of query vertices u3, u4, and u5 being selected for the generation operation. Among them, the probability of query vertex u3 with the corresponding vertex label C is the highest, so the generation operation of query vertex u3 with the vertex label C is added to the search plan 506, and the query vertex u3 is added to the extended candidate pool 508.

[0091] In operation 405 , the expansion module 330 utilizes a multi-layer perceptron to evaluate each query vertex in the expansion candidate pool to evaluate whether the query vertex should perform an expansion operation.

[0092] In operation 406 , the expansion module 330 removes query vertices that require expansion operations from the expansion candidate pool and adds them to the search plan, and retains query vertices that do not require expansion operations in the expansion candidate pool.

[0093] See Figure 5 As shown in part (c): “Expand”, each query vertex in the expansion candidate pool 508 is evaluated by a multi-layer perceptron (i.e., Classification MLP 509) to determine whether each query vertex performs an expansion operation or not, as shown in FIG. Figure 5 As shown, after the four query vertices in the extended candidate pool 508 are evaluated by the multilayer perceptron, two query vertices 509 are evaluated as needing to perform an extension operation, so the two query vertices are removed from the extended candidate pool 508, and the extension operations of the two query vertices 509 are added to the search plan 506.

[0094] In operation 407, it is determined whether all query vertices in the query graph have undergone the generation operation. If all query vertices in the query graph have undergone the generation operation, the process proceeds to operation 408; if there are query vertices in the query graph that have not undergone the generation operation, the process returns to operation 403 and loops downward.

[0095] In operation 408 , the expansion operations for the remaining query vertices in the expansion candidate pool are automatically added to the search plan, and the process ends here.

[0096] In this embodiment, the generation operation performed by the generation module 320 is responsible for calculating a local candidate set for each query vertex, namely, operations 403 and 404 performed by the generation module 320. If the local candidate set is found to be empty, it indicates the termination of the current subgraph matching search. The expansion operation performed by the expansion module 330 is responsible for retrieving and expanding the local candidate set of the query vertex from the expanded candidate pool, namely, operations 405-408 performed by the expansion module 330.

[0097] When all query vertices have undergone both the generate and expand operations, the search plan generation is complete. A complete operation-level search plan is formed when each query vertex appears twice in the operation-level search plan: once for the generate operation and once for the expand operation.

[0098] The functions of the graph feature extraction module 310 , the generation module 320 , and the expansion module 330 are further described below to further illustrate the technical details of the subgraph matching search plan generation provided by the embodiment of the present application.

[0099] 1. Graph feature extraction module 310

[0100] The graph feature extraction module 310 first generates a feature vector for each query vertex, and then converts these feature vectors into a representation of each query vertex using a graph neural network (GNN). The heuristic method used in the prior art to generate a matching order mainly depends on the degree, label, and estimated size of the candidate vertex. In the embodiment of the present application, based on the prior art, feature metrics related to local candidate generation and expansion are added. Specifically, four feature metrics are added: a first feature metric, a second feature metric, a third feature metric, and a fourth feature metric.

[0101] In this embodiment, the design of a feature metric first evaluates the degree, label, and estimated candidate set size. The first feature metric counts the number of vertices in the statistical graph that have at least the same degree and matching label as the query vertex, thereby estimating the candidate set size for each query vertex. In the early stages of search plan generation, query vertices with smaller estimated candidate sets can be prioritized to minimize the search space expansion in the early subgraph matching phase. The first feature metric is defined as follows:

[0102] f1(u)=|{v∈G|d(u) <d(v)&&L(u)=L(v)}|. (10)

[0103] Where u is a query vertex in the query graph, G is the set of all vertices in the data graph, v belongs to G indicates traversing the vertices in the data graph, d(u) and d(v) represent the degrees (i.e., the number of connected edges) of query vertex u and vertex v, respectively, and L(u) and L(v) represent the labels of query vertex u and vertex v, respectively.

[0104] As mentioned earlier, generating local candidates for the right neighbors of the query vertex involves applying stricter topological constraints. The extent to which the query vertex's neighbors have completed the expansion (exp) operation also affects the generation of its local candidates, potentially reducing the size of the local candidate set. If no local candidate set is found, this may lead to early termination of the subgraph matching process. Therefore, the second feature metric evaluates this by counting the number of neighbors among the neighbors of the current query vertex v that have completed the expansion operation to evaluate the potential impact of estimating the candidate set size of the current query vertex. The second feature metric is defined as follows:

[0105] f2(u)=|{u′∈N q (u)|exp(u′)in search plan}|. (11)

[0106] Wherein, u is the current query vertex, u′ represents the neighbor of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, and exp(u′)in search plan represents whether the neighbor u′ has been expanded in the search plan.

[0107] If the current query vertex u has many neighbors that have not yet completed the generation (gen) operation, performing the expansion operation on the current query vertex u can simultaneously impose stricter constraints on the pending generation operations of these neighbors. Therefore, in the embodiment of the present application, a third characteristic metric is used to quantify the number of neighbors waiting for the generation operation among the neighbors of the current query vertex u, so as to evaluate the potential impact of the neighbors of the current query vertex that have not completed the generation operation on the estimated candidate set size when it subsequently becomes the current query point. The third characteristic metric is defined as follows:

[0108] f3(u)=|{u′∈N q (u)|gen(u′)not in search plan}|. (12)

[0109] Where u is the current query vertex, u′ represents the neighbors of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, gen(u′)in searchplan represents whether the candidate generation operation of neighbor u′ is already in the search plan, and the symbol “|…|” represents the number of neighbors that meet the conditions.

[0110] The size of the local candidate set generated by the current query vertex u in the query graph tends to decrease as more query vertices with the same label as the current query vertex u are expanded. In order to quantify this and more accurately evaluate the estimated candidate set size of the current query vertex u, the fourth feature metric is used in the embodiment of the present application to calculate the local candidate set size of the query graph q with the query vertex u.

[0111] u is the number of vertices with the same label that have undergone local candidate expansion. The fourth metric is calculated as follows:

[0112]

[0113] Wherein, u is the current query vertex, u′ represents any query vertex in the query graph, V(q) is the set of all query vertices in the query graph q, L(u′) and L(u) represent the labels of the query vertex u′ and the current query vertex u, respectively, and exp(u′)in search plan indicates whether the query vertex u′ has been expanded in the search plan.

[0114] In addition, in order to reflect the evolving focus in the search plan, two feature metrics are added in the embodiment of the present application: a fifth feature metric and a sixth feature metric. The fifth feature metric is used to calculate the number of query vertices that have completed the generation operation, and the sixth feature metric is used to calculate the number of query vertices that have completed the expansion operation:

[0115] f5(u)=|{u∈V(q)|gen(u)in search plan}|, (14)

[0116] f6(u)=|{u∈V(q)|exp(u)in search plan}|. (15)

[0117] Wherein, u is a query vertex in the query graph, V(q) represents the set of all query vertices in the query graph q, gen(u)in search plan represents whether the candidate generation operation of query vertex u has been included in the search plan, and exp(u)in search plan represents whether the query vertex u has been expanded in the search plan.

[0118] In addition, in the embodiment of the present application, an indicator variable f7(u) is added to indicate whether the current query vertex u has completed the generation operation, and an indicator variable f8(u) is added to indicate whether the current query vertex u has completed the expansion operation. If the operation is completed, the corresponding indicator variable is set to 1, otherwise it is 0:

[0119] f7(u)=1,if gen(u)in search plan, (16)

[0120] f8(u)=1,if exp(u)in search plan. (17)

[0121] In the embodiments of this application, a graph neural network is used to generate node representations. Specifically, a graph convolutional network (GCN) is used to convert the feature vector of the query vertex into a representation through a message passing algorithm on the graph, allowing each query vertex to learn a representation that contains its local neighborhood context information. The mathematical expression for the representation of the query graph using GCN is as follows:

[0122]

[0123] Among them H (l) is the query vertex representation matrix of the lth layer; is the enhanced adjacency matrix A of the graph, by adding self-connections I N (identity matrix) to expand; yes The diagonal query vertex degree matrix, W (l) is the weight matrix of the lth layer, σ(·) represents the nonlinear activation function, such as ReLU, H (l+1) is the query vertex representation matrix of the l+1th layer.

[0124] 2. Generate module 320

[0125] After obtaining the representation of each query vertex, the generation module 320 first uses an activation process to define the action space of the generation module 320 in the current state. Subsequently, the generation module 320 uses a multilayer perceptron (MLP) to select the query vertex for which the generation operation should be performed (i.e., select the current query vertex). In this embodiment of the present application, the generation process is iteratively refined.

[0126] Activation process of action space: After learning the node representation (output of the last layer of GNN), the activation process is used to determine which query vertices are eligible to be included in the action space of the generation module in the current state. In the embodiment of the present application, a query vertex u can only be included in the action space of the generation module in the current state if at least one of its neighbor vertices has completed the expansion process and the query vertex u itself has not completed the generation operation. For example, in Figure 3 In , if the query vertex u1 has already performed the generate and expand operations, the search plan is represented as u1→u1 (the first u1 represents gen(u1) and the second represents exp(u1). In this case, only u2, u3 and u4 can pass the mask. This is because u5 and u6 have no neighbors that have completed the expand operation and no further operations need to be added to the search plan. According to the existing mask criteria, a heuristic algorithm can be used to determine the initial query vertex of the search plan, for example, the query vertex u′ with the highest degree is selected to perform the gen(u′) and exp(u′) operations first, thereby setting the initial state of the search plan to u′→u′.

[0127] MLP is used to select vertices for generative operations: given each step in the query graph

[0128] The node of t represents H t , and the action space (AS) defined for the generation module, a two-layer MLP (Multi-layer Perceptron) calculates the selection probability of generating local candidates for each query vertex in the AS. The probability calculation formula is as follows:

[0129] P t (u i )=MLP(H t (u i )), (19)

[0130] where u i is a query vertex, u i ∈AS,H t (u i ) represents the query vertex u i The initial representation at the t iteration step. Subsequently, the softmax function is applied to all the calculated probability values for normalization. The query vertex with the highest probability after softmax is selected as the output action of the generation module for this iteration. The selection process can be described mathematically as follows:

[0131]

[0132] where u * is the vertex selected as the output of the action of the generating module. * After that, the model first converts u *Add it to the search plan as a generation operation, and then * Added to the extension candidate pool so that the extension module can evaluate u * Whether it is suitable for expansion operations.

[0133] Follow-up: After selecting the vertex u * After that, the model first converts u * As a generation operation (gen) into the search plan. Next, it will u * Added to the Expansion Candidate Pool so that the expansion module can evaluate u * The feasibility of performing the expansion operation (exp).

[0134] 3. Extension module 330

[0135] The module uses a binary function to evaluate whether each node in the pool of expansion candidates should be expanded, evaluating each node separately. In extreme cases, all query vertices in the pool may be expanded, or none may be. The operation of the expansion classifier is contained in the following equation:

[0136]

[0137] Among them E(u j ) represents the expanded vertex u j Classifier(·) is the extended classifier function used to evaluate the query vertex u j Should it be expanded? If u j Assessed as ready for expansion, u j will be transferred from the expansion candidate pool to the search plan as u j If not, u j It is then retained in the expanded candidate pool for subsequent consideration. To simplify the process, once the generation operations for all query vertices have been added to the search plan, any vertices remaining in the expanded candidate pool will automatically be included in the search plan.

[0138] Please continue reading Figure 5 As shown in Section (d) “Reward and Back Propagation”, in this embodiment of the present application, the subgraph matching search plan generation method is also modeled as a reinforcement learning process, which includes the following key elements:

[0139] State: In the generation module 320 and the expansion module 330, the state consists of the representation of each query vertex in the graph feature extraction module 310 and the construction state of the current search plan.

[0140] Action: The action space of the generation module 320 consists of the nodes activated during the activation process. The actions in the generation module 320 are determined based on the selection probability of each vertex, which is calculated from the vertex's representation. The vertex with the highest probability is then selected and inserted into the search plan and the expansion candidate pool. During the expansion process, the action space consists of the vertices in the expansion candidate pool. The expansion module 330 evaluates whether the expansion operation should be performed for each vertex in the current state.

[0141] Reward: This is a key component in reinforcement learning, the reward function. There are two main considerations for reward function design: (a) Reducing the search space: Reinforcement learning-based methods achieve a reduced search space compared to traditional strategies; (b) Reducing the number of local candidate generation: This metric calculates the reduction in the number of gen executions during the search process, indicating the efficiency of the search plan. Finally, the reward function is calculated by comparing the search space (SP) and the number of local candidate generation (GT), as shown below:

[0142] r SP =SP Hybrid -SP RL , (1)

[0143] r GT =GT Hybrid -GT RL , (2)

[0144]

[0145] R=R SP +R GT , (5)

[0146] Among them, r GT The raw difference of search space reduction is a direct comparison of the search space size between the reinforcement learning-based approach in this application and the traditional approach.

[0147] SP Hybrld represents the size of the search space generated by the traditional method (here referred to as "Hybrid", i.e., conventional method);

[0148] SP RL Indicates the size of the search space generated by the reinforcement learning-based method in this application;

[0149] r GTRepresents the raw difference of generating local candidates times reduction;

[0150] GT Hybrld represents the total number of generation operations performed by the traditional method (traditional strategy, Hybrid) during the search process;

[0151] GT RL represents the total number of times the reinforcement learning-based method in this application performs generation operations during the search process;

[0152] R represents the final total reward value (total reward), which is the sum of the search space reduction reward and the generation number reduction reward.

[0153] Since early actions have a significant impact on the results, in this embodiment of the application, a decay factor is used to calculate the reward for each action, as shown below:

[0154]

[0155] where |{actions}| represents the total number of actions generated by the search plan, and the decay factor γ captures the decreasing effect of the action sequence on the cumulative reward, highlighting the temporal aspect of the search plan generation operation.

[0156] See also Figure 5 As shown in part (d): "Reward and Back Propagation", for the query graph 500 and the data graph 501, the search plan 510 generated by the subgraph matching search plan generation method based on reinforcement learning in the embodiment of the present application and the search plan 511 generated by the traditional method are respectively used for subgraph matching, and rewards are given based on the comparison of the results of the two.

[0157] Policy Training: The training process uses |{actions}| training query graphs and a single data graph. The goal is to optimize the expected reward of the policy network π(θ) using these training graphs. In the training batch, let θ represent the network parameters, and the reward function at any time step t is expressed as:

[0158]

[0159] Where: r t (θ) represents the reward at time step t, parameterized by θ. t represents the final time step of the training set. Φ i Represents the network parameters θ t Query graph q i Generated search plan. i (Φ iθ t ) represents the query graph q t With search plan Φ i To optimize our framework, we use Proximal Policy Optimization (PPO) with the following loss function:

[0160]

[0161] in Indicates that in the current strategy π θ and traditional strategies Next, take action t The probability ratio. represents the advantage of an action compared to the average level (or baseline) at time step t. The clip(·) function limits this ratio to [1-∈, 1+∈], where ∈ is a small hyperparameter (e.g., 0.2) that limits the deviation of the current policy from the traditional policy.

[0162] The present application also provides a subgraph matching search plan generation device. Figure 6 As shown, this is a hardware structure diagram of the subgraph matching search plan generation device for running the subgraph matching search plan generation method of the present application. The device 60 includes a processor 601, a memory 603, a communication bus 605, at least one network interface 607 or a user interface 609. The user interface 609 can be, for example, a display, a keyboard or a clicking device. The memory 603 can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The memory 603 stores execution instructions. When the processor 601 runs, the processor 601 communicates with the memory 603, and the processor 601 calls the instructions stored in the memory 603, i.e., the subgraph matching search plan generation program 100, to execute the above-mentioned subgraph matching search plan generation method. The device 60 also includes an operating system 611, which contains various programs for implementing various basic services and processing hardware-based tasks.

[0163] The device 60 provided in the embodiment of the present application, the processor 601 can execute the operations included in the above-mentioned sub-graph matching search plan generation method to optimize the sub-graph matching search plan generation. Its implementation principle and technical effects are similar to the sub-graph matching search plan generation method introduced in the above-mentioned embodiment, and the details will not be repeated here.

[0164] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, which may be, for example, a memory 603. The computer-executable instructions enable a processing unit (such as a processor 601) to execute the subgraph matching search plan generation method described in the above embodiment. The implementation principle and technical effect of the method are similar to the subgraph matching search plan generation method introduced in the above embodiment, and will not be repeated here.

[0165] An embodiment of the present application also provides a computer program product, which includes computer-executable program instructions, and the computer-executable program instructions can enable a processing unit (such as processor 601) to execute the sub-graph matching search plan generation method described in the above embodiment. Its implementation principle and technical effect are similar to the sub-graph matching search plan generation method introduced in the above embodiment, and will not be repeated here.

[0166] In summary, the subgraph matching search plan generation method, device, storage medium and computer program product provided in the embodiments of the present application propose a new operation-level search paradigm, which regards the generation (gen) operation and the expansion (exp) operation as independent computing units, eliminating the need for the generation operation and the expansion operation to occur at the same time. Compared with the traditional expansion-level search, this can reduce the search space and the number of generation operations. Secondly, the use of reinforcement learning strategies to generate operation-based search plans is an innovative attempt to guide the search process more effectively. Furthermore, by using graph neural networks, it is possible to capture the structural features in the data graph and the query graph, provide more accurate context information for the generation and expansion operations, improve the efficiency of subgraph matching, and reduce the search cost.

[0167] The above description is merely an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method for generating a subgraph matching search plan, characterized in that: The method comprises: Initialize the features of each query vertex of the query graph using a heuristic strategy to obtain the initialized features of each query vertex; Utilize graph neural networks to capture the representation of each query vertex; identifying a query vertex in an action space through an activation process, wherein the action space consists of query vertices that have not completed a generate operation themselves but have at least one neighbor that has completed an expand operation; Using a multilayer perceptron to calculate the probability of each query vertex being selected for a generation operation based on representations of the query vertices in the action space, adding the generation operation of the query vertex with the highest probability to a search plan, and adding the query vertex with the highest probability to an expanded candidate pool; evaluating each query vertex in the expansion candidate pool using a multilayer perceptron to evaluate whether an expansion operation should be performed on each query vertex; Removing query vertices that require an expansion operation from the expansion candidate pool and adding them to the search plan, and retaining query vertices that do not require an expansion operation in the expansion candidate pool; Determining whether all query vertices in the query graph have undergone a generation operation; and In a case where all query vertices in the query graph have undergone a generation operation, the expansion operations of the remaining query vertices in the expansion candidate pool are automatically added to the search plan.

2. The method according to claim 1, characterized in that Also includes: If there is a query vertex in the query graph that has not undergone a generation operation, the process returns to the step of "identifying the query vertex in the action space through the activation process" and continues to execute.

3. The method according to claim 1, characterized in that The “initializing the features of each query vertex of the query graph using a heuristic strategy” further includes: The number of vertices in the statistical graph that have at least the same degree and matching label as each query vertex is calculated using a first feature metric, thereby estimating the size of the candidate set for each query vertex, wherein the first feature metric is defined as follows: f1(u)=|{υ∈G|d(u)<d(υ)&&L(u)=L(υ)}|. Where u is a query vertex in the query graph, G is the set of all vertices in the data graph, v belongs to G means traversing the vertices in the data graph, d(u) and d(v) represent the degrees of query vertex u and vertex v respectively, L(u) and L(v) represent the labels of query vertex u and vertex v respectively; The second characteristic metric is used to calculate the number of neighbors of the current query vertex that have completed the expansion operation, wherein the second characteristic metric is defined as follows: f2(u)=|{u′∈N q (u)|exp(u′)in search plan}|. Where u is the current query vertex, u' represents the neighbors of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, and exp(u')in search plan represents whether the neighbor u' has been expanded in the search plan; A third characteristic metric is used to quantify the number of neighbors of the current query vertex waiting for the generate operation, wherein the third characteristic metric is defined as follows: f3(u)=|{u′∈V q (u)|gen(u′)not in search plan}|. Where u is the current query vertex, u' represents the neighbors of the current query vertex u, Nq(u) represents the set of neighbors of the current query vertex u, gen(u')in search plan indicates whether the candidate generation operation of neighbor u' is already in the search plan, and the symbol "|…|" represents the number of neighbors that meet the conditions; and The fourth feature metric is used to calculate the number of vertices in the query graph that have the same label as the current query vertex and have undergone local candidate expansion, wherein the fourth feature metric is defined as follows: Wherein, u is the current query vertex, u' represents any query vertex in the query graph, V(q) is the set of all query vertices in the query graph q, L(u') and L(u) represent the labels of the query vertex u' and the current query vertex u, respectively, and exp(u')in search plan indicates whether the query vertex u' has been expanded in the search plan.

4. The method according to claim 3, characterized in that The “initializing the features of each query vertex of the query graph using a heuristic strategy” further includes: The fifth characteristic metric is used to calculate the number of query vertices that have completed the generation operation, where the fifth characteristic metric is defined as follows: f5(u)=|{u∈V(q)|gen(u)in search plan}| Where u is a query vertex in the query graph, V(q) represents the set of all query vertices in the query graph q, and gen(u)in search plan indicates whether the candidate generation operation for query vertex u has been included in the search plan; The sixth characteristic metric is used to calculate the number of query vertices that have completed the expansion operation, where the sixth characteristic metric is defined as follows: f6(u)=|{u∈V(q)|exp(u)in search plan}| Wherein, u is a query vertex in the query graph, V(q) represents the set of all query vertices of the query graph q, and exp(u)in search plan represents whether the query vertex u has been expanded in the search plan.

5. The method according to claim 1, wherein The “capturing the representation of each query vertex using the graph neural network” includes: using a graph convolutional network to convert the feature vector of each query vertex into a representation through a message passing algorithm on the graph, allowing each query vertex to learn a representation that includes its local neighborhood context information, wherein the mathematical expression for representing the representation of the query graph using the graph convolutional network is as follows: Among them, H (l) is the query vertex representation matrix of the lth layer; is the enhanced adjacency matrix A of the graph, by adding self-connections I N The identity matrix is expanded; yes The diagonal query vertex degree matrix, W (l) is the weight matrix of the lth layer, σ(·) represents the nonlinear activation function, H (l+1) is the query vertex representation matrix of the l+1th layer.

6. The method according to claim 1, characterized in that A two-layer multilayer perceptron is used to calculate the probability of each query vertex being selected for the generation operation in the action space. The probability calculation formula is as follows: P t (u i )=MLP(H t (u i )), Among them, u i is the query vertex, u i ∈AS,H t (u i ) represents the query vertex u i The initial representation at t iteration steps, The “adding the query vertex with the highest probability to the search plan and the expanded candidate pool” includes: All the calculated probability values are normalized by applying the softmax function. After normalization, the query vertex with the largest probability value is added to the search plan and the expanded candidate words. The calculation formula for selecting the query vertex with the largest probability value is as follows: Among them, u * Represents the query vertex with the largest probability value.

7. The method according to claim 6, characterized in that An expansion classifier is used to evaluate whether each query vertex in the expansion classification pool should perform an expansion operation: Among them, E(u j ) represents the selection of query vertex u j The decision to perform the expansion operation, Classifier(·) is the expansion classifier function, which is used to evaluate the query vertex u j Whether it should be expanded.

8. A subgraph matching search plan generation device, characterized in that: The subgraph matching search plan generating device comprises: a memory configured to store computer-executable instructions; A processor configured to execute computer-executable instructions stored in the memory to implement the subgraph matching search plan generation method according to any one of claims 1 to 7.

9. A storage medium, characterized in that: The storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processing unit, the subgraph matching search plan generation method according to any one of claims 1 to 7 is implemented.

10. A computer program product, characterized in that The method comprises computer program instructions, which, when executed by a processing unit, implements the subgraph matching search plan generation method according to any one of claims 1 to 7.