Sub-graph matching query method and device based on same subsequent node compression
By generating auxiliary structures and using the maximum delete edge algorithm to generate query plans, and fine-tuning the query plans, the problem of sharp increase in the complexity of sub-graph matching query is solved, and efficient query processing is achieved.
Patent Information
- Application Number
- CN202411683737.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-11-22
AI Technical Summary
In the prior art, as the number of query graph nodes increases, the complexity of sub-graph matching query increases rapidly like an exponential explosion, resulting in inefficient query.
By generating an auxiliary structure corresponding to the query graph, including the set of candidate nodes corresponding to each query graph node and the set of candidate edges corresponding to each query graph edge, the maximum deletion edge algorithm is used to generate the optimal query plan, and the nodes with the same successor are classified into equivalent sets for fine-tuning, and the query process is finally executed based on the fine-tuned query plan.
It effectively reduces the overhead of sub-graph matching queries, can efficiently process larger-scale query graphs, and reduces search complexity.
Smart Images

Figure CN119537653A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of subgraph matching, and in particular, to a subgraph matching query method and device based on compression of identical successor nodes. Background Art
[0002] As a data type with very powerful descriptive capabilities, graph data has been widely used in many fields such as biological macromolecule analysis, financial fraud detection, social network analysis, knowledge graph query, etc. In recent years, with the continuous development of graph data applications, not only the scale of data graphs has become larger and larger, but also the scale of query graphs has become larger and larger, and the structure has become more and more complex. This type of query is highly complex and time-consuming, and requires more efficient algorithms to optimize. Large and complex queries are also one of the inevitable trends in the future development of graph database systems.
[0003] Subgraph isomorphism query is one of the most commonly used operations in graph data analysis queries. It is also a classic type of non-deterministic polynomial (NP) complete problem with polynomial complexity. The complexity of brute force search is O(|V(G)| |V(Q)| ), where V(G) and V(Q) are the node sets in the query graph and the large data graph, respectively. It can be seen that with the increase in the number of query graph nodes, the search complexity increases exponentially. Therefore, the difficulty brought by the growth of the query graph scale is much higher than the difficulty brought by the growth of the data graph scale. Therefore, a more efficient compression algorithm is needed to compress the query graph scale to a greater extent and reduce the search complexity. Summary of the invention
[0004] The main purpose of the embodiments of the present invention is to provide a subgraph matching query method and device based on compression of the same successor nodes, which reduces the overhead of subgraph matching queries, can more efficiently process larger-scale query graphs, and solve the problem in the prior art that the complexity of the search increases exponentially as the number of query graph nodes increases.
[0005] In a first aspect, a subgraph matching query method based on compression of identical successor nodes is provided, the method comprising: generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure comprising a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; generating an optimal arrangement of the node set in the query graph according to the maximum deletion edge algorithm of the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with identical successors in the query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; executing the query process according to the fine-tuned query plan to obtain a subgraph matching query result.
[0006] In another possible implementation, an auxiliary structure corresponding to the query graph is generated based on the query graph and the data graph, including: initializing a candidate edge set for each query graph edge in the query graph based on the data graph; removing false positive candidate edges in each candidate edge set to generate an auxiliary structure corresponding to the query graph.
[0007] In a possible implementation, a candidate edge set is initialized for each query graph edge in the query graph according to the data graph, including: for any query graph edge (u i ,u j ), if there is a data graph edge (v i ,v j ), query graph node u j The labels and data graph nodes v i The labels are the same, and the query graph node u i The degree is less than or equal to the data graph node v i The degree of the data graph edge (v i ,v j ) is the query graph edge (u i ,u j ) candidate edges; scan the edges in the data graph to obtain the query graph edges (u i ,u j ) to obtain the initialized candidate edge set.
[0008] In another possible implementation, false positive candidate edges in each candidate edge set are removed to generate an auxiliary structure corresponding to the query graph, including: treating the candidate edge set of each query graph edge as a relationship table; semi-joining the relationship table with the relationship tables corresponding to all neighbor edges of the query graph edge to remove false positive candidate edges in the candidate edge set; repeating multiple times until all false positive candidate edges are filtered out to generate an auxiliary structure corresponding to the query graph.
[0009] In another possible implementation, the query plan is fine-tuned according to the equivalence sets, including: determining the order of each equivalence set according to the query plan according to the arrangement order of the last query graph node in each equivalence set; moving the nodes other than the last query graph node in each equivalence set to the front of the last query graph node in the order of each equivalence set from back to front, and keeping the original node arrangement order unchanged, to obtain a fine-tuned query plan.
[0010] In another possible implementation, the query process is executed according to the fine-tuned query plan to obtain the subgraph matching query result, including: initializing a corresponding cache area for caching the matching result for each equivalence set; performing a depth-first search according to the fine-tuned query plan; for the current state M of the kth layer, calculating the matching k+1th node u cA node set, where the nodes in the node set are from node u c Selected from the candidate node set, and all matching nodes u c The nodes adjacent to the predecessor neighbor nodes connect each node in the node set to node u c Matching is performed to obtain a new next-layer state M′; for any equivalence set S, when the search process traces back to the depth of the deepest layer S[-1], the matching node set at this time is cached as the cache key, and S[-1] is the node in the deepest layer of the query plan in the equivalence set S; the nodes in the matching node set are rearranged according to the node order in the query plan to obtain the subgraph matching query result.
[0011] In another possible implementation, the query process is executed according to the fine-tuned query plan to obtain the subgraph matching query result, which also includes: for an equivalence set, if the forward search reaches the depth of the deepest node S[-1], the node set that has matched the equivalence set S is placed in the cache area for query, and if a hit is found, the current branch is pruned, otherwise the search continues; if the current backtracking reaches the depth of the shallowest node S[0], the cache area corresponding to the equivalence set S is cleared.
[0012] In a second aspect, a subgraph matching query device based on compression of identical successor nodes is provided, the device comprising: an auxiliary structure generation module, for generating an auxiliary structure corresponding to a query graph according to a query graph and a data graph, the auxiliary structure comprising a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; a plan generation module, for generating an optimal arrangement of a set of nodes in a query graph using a maximum deleted edge algorithm according to the query graph and the auxiliary structure, and obtaining an optimal query plan; a plan fine-tuning module, for grouping nodes with identical successors in a query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; and a matching query module, for executing a query process according to the fine-tuned query plan, and obtaining a subgraph matching query result.
[0013] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a subgraph matching query method based on compression of identical successor nodes as provided in the first aspect is implemented.
[0014] In a fourth aspect, a non-transitory computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, a subgraph matching query method based on compression of identical successor nodes as provided in the first aspect is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.
[0016] Figure 1 A flowchart of a subgraph matching query method based on compression of identical successor nodes provided by one embodiment of the present invention;
[0017] Figure 2 A schematic diagram of auxiliary structure generation provided by an embodiment of the present invention;
[0018] Figure 3 A schematic diagram of a depth-first search provided by an embodiment of the present invention;
[0019] Figure 4 A schematic diagram of fine-tuning a query plan provided by an embodiment of the present invention;
[0020] Figure 5 A structural diagram of a subgraph matching query device based on compression of identical successor nodes provided by one embodiment of the present invention;
[0021] Figure 6 A schematic diagram of the physical structure of an electronic device provided by the present invention.
[0022] Specific implementation method
[0023] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar modules or modules with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present invention.
[0024] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "a", "an", "said" and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, modules and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, modules, components and / or groups thereof. It should be understood that when we refer to a module as being "connected" or "coupled" to another module, it may be directly connected or coupled to the other modules, or there may be intermediate modules. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any modules and all combinations of one or more associated listed items.
[0025] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation method of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0026] The technical solution of the present application and how to solve the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0027] like Figure 1 FIG. 1 is a flow chart of a subgraph matching query method based on compression of identical successor nodes provided by an embodiment of the present invention, the method comprising:
[0028] Step S11, generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure including a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge.
[0029] Step S12, generating an optimal arrangement of the node set in the query graph by using a maximum deleted edge algorithm according to the query graph and the auxiliary structure, and obtaining an optimal query plan.
[0030] The maximum deleted edges algorithm (MDE) is mainly used to generate the corresponding query plan. It is the optimal arrangement of the query graph node set, which is used to guide the subsequent depth-first algorithm search process.
[0031] Step S13, grouping the nodes with the same successor in the query plan into an equivalence set, and fine-tuning the query plan according to the equivalence set.
[0032] Step S14, executing the query process according to the fine-tuned query plan to obtain the subgraph matching query result.
[0033] The embodiment of the present invention performs a subgraph matching query based on compression of the same successor node, and can obtain an equivalent set according to a query plan and fine-tune the query plan according to the equivalent set, thereby achieving the purpose of compressing a large query graph, thereby reducing the overhead of the subgraph matching query and being able to process larger-scale query graphs more efficiently.
[0034] In the embodiment of the present invention, in step S11, a candidate edge set is first initialized for each query graph edge in the query graph according to the data graph. i ,u j ), if there is a data graph edge (v i ,v j ), query graph node u i The labels and data graph nodes v iThe labels of the query graph nodes are the same, and the degree of the query graph node ui is less than or equal to the data graph node v i The degree of the data graph edge (v i ,v j ) is the query graph edge (u i ,u j ) candidate edges; scan the edges in the data graph to obtain the query graph edges (u i ,u j ) to obtain the initialized candidate edge set.
[0035] Then, the false positive candidate edges in each candidate edge set are removed to generate an auxiliary structure corresponding to the query graph. i ,u j ) is regarded as a relation table R(u i ,u j ); the relation table R(u i ,u j ) and the query graph edge (u i ,u j ) Perform semi-join processing on the relationship tables corresponding to all neighbor edges, and remove false positive candidate edges in the candidate edge set; repeat multiple times until the filtered relationship table R(u i ,u j ) to generate an auxiliary structure corresponding to the query graph The specific number of repetitions can be set as needed and is not specifically limited here. Preferably, it is repeated 3 times. Figure 2 , generate auxiliary structure based on query graph Q and data graph G The candidate nodes corresponding to each query graph node are stored in a very compact way, and the edges connecting the candidate nodes represent the candidate edge set, where the query graph node u 0 The candidate node set Includes data graph node v 0 、v 1 and v 2 , query graph node u 1 The candidate node set Includes data graph node v 3 and v 4 , query graph node u 2 The candidate node set Includes data graph node v 5 and v 6 , query graph node u 3 The candidate node set Includes data graph node v 9 …v 100 , query graph node u 4 The candidate node set Includes data graph node v 0 、u 1 and v 2 , query graph node u 5 The candidate node set Including data graph node u 7 and v 8 .
[0036] In step S13, according to the query plan For each query graph node u, its neighbors are divided into two parts. One part is the neighbors that are located before the query graph node u in the search order, called the predecessor neighbors of the query graph node u, denoted by N + (u), and the other part is the neighbors that are located after the query graph node u in the search order, called the successor neighbors of the query graph node u, and recorded as N - (u). Nodes with the same successor neighbors are grouped into an equivalent set S, that is, N - (u 1 )-S=N - (u 2 )-S, e.g. Figure 3 in, u 1 ,u 3 belong to the same equivalence set because their successor neighbors are the same, that is, {u 3 ,u 4}-{u 1 ,u 3}={u 4}-{u 1 ,u 3}.
[0037] After obtaining each equivalence set, fine-tune the query plan according to the equivalence set. The basic idea is to move the search order of the nodes in the same equivalence set closer to the position of the last node. First, according to the query plan, determine the order of each equivalence set according to the arrangement order of the last query graph node in each equivalence set. For each equivalence set S, S[-1] is recorded as the order according to the plan. In the order of S[-1], the last node in S is sorted, and all equivalent sets are arranged in the order of S[-1]. For example, Figure 4 Assume that there are two equivalent sets S 1 = {u 1 ,u 3} and S 2 = {u 0 ,u 2 ,u 5}, marked with the same fill pattern, their last nodes are S1 [-1] = u 3 , S 2 [-1] = u 5 , so after sorting, it is an equivalent set S 1 Arrange in the equivalent set S 2 Before.
[0038] Then, according to the order between equivalent sets, the node search order in each set is fine-tuned from back to front. According to the order of each equivalent set from back to front, move the nodes other than the last query graph node in each equivalent set to the front of the last query graph node, and keep the original node arrangement order unchanged to obtain the fine-tuned query plan. Specifically, first process the set equivalent set S 2 , the equivalent set S 2 All other nodes in the 2 [-1] = u 5 Go straight ahead and keep the original relative order, so you get a new plan Then the same thing happened to S 1 Similar operations can be used to plan the final Following this from back to front, we can ensure that the equivalence relation within each equivalence set is not destroyed. Figure 4 In the example, nodes with the same fill pattern indicate that they belong to the same equivalence set. in, u 2 ,u 5 Belong to the same equivalence set, and the node u 2 Move from the original third position to u 5 Before the position, so that the nodes in this equivalence set are in the new plan The same operation is performed for other equivalent sets, and finally a fine-tuned plan is obtained. The nodes in the same equivalence set are arranged together and their successor neighbors are guaranteed to be the same.
[0039] After fine-tuning the query plan, based on the final query plan Start to perform depth-first search. In step S14, initialize a corresponding cache area for caching matching results for each equivalent set; perform depth-first search according to the fine-tuned query plan. For the current state M of the kth layer, calculate the matching k+1th node u c A node set, where the nodes in the node set are from node u c Selected from the candidate node set, and all matching nodes u c The nodes adjacent to the predecessor neighbor nodes connect each node in the node set to node u cMatch and get the new next layer state M'. Before starting the search, first initialize a corresponding cache for each equivalent set to cache its matching results. For the current state M of the kth layer, calculate the k+1th node in the matching plan. The node set C(u c ), these nodes are from auxiliary structures middle u c Selected from the candidate node set and can match all u c The nodes of the predecessor neighbors are adjacent. When the node set C(u c ), then traverse each node v c , and compare it with u c Match, and get the new state of the next layer M′=M+(u c ,v c ).
[0040] Apply Cache to cache the results. For an equivalence set S, S[0] and S[-1] are respectively recorded as the nodes at the shallowest and deepest levels of the query plan in the equivalence set S. For any equivalence set S, when the search process traces back to the depth of the deepest layer S[-1], the set of matching equivalent nodes at this time is cached as the cache key, and S[-1] is the node at the deepest level of the query plan in the equivalence set S. For example Figure 3 , for the equivalent set S 1 =u 1 ,u 3 , S 1 [0] = u 1 , S 1 [-1] = u 3 , when the search process traces back to the deepest node S 1 [-1], cache the matching equivalent node set at this time as the cache key. In this example, the corresponding matching equivalent node set {v 1 ,v 3} as the key to cache.
[0041] Then the found results are rearranged, and after caching the matching equivalent node set v 1 ,v 3 , these nodes are rearranged to obtain new results. That is, the nodes in the matching equivalent node set are rearranged according to all possibilities to obtain new subgraph matching query results. For details, see Figure 3 , when backtracking to state M 4 , assuming the search returns a matching result {u 0 :v 0 ,u 2 :v 2 ,u1 :v 3 ,u 3 :v 1 ,u 4 :v 4 ,u 5 :v 5}, then its equivalent set S 1 = {u 1 ,u 3}, we can get a new match {u 0 :v 0 ,u 2 :v 2 ,u 1 :v 1 ,u 3 :v 3 ,u 4 :v 4 ,u 5 :v 5}, that is, it will match u 1 ,u 3 The nodes are exchanged, and the matching result needs to be verified whether it is isomorphic. If so, it is output as the result, otherwise it is directly filtered out.
[0042] In the embodiment of the present invention, if the cache hits in the subsequent search process, the current redundant branch is deleted. For an equivalent set, if the deepest node S[-1] is searched forward, the node set that has matched the equivalent set S is put into the cache area for query. If it hits, it means that all the results under the current branch have been output through the previous rearrangement operation, and there is no need to repeat the search. The current branch is directly pruned, otherwise the search continues.
[0043] In the subsequent search process, when the search depth is traced back to a place outside the equivalence set, the cache results related to this equivalence set in the Cache are cleared. For an equivalence set S, if the current traceback reaches the depth where the shallowest node S[0] is located, the cache area corresponding to the equivalence set S is cleared. For example Figure 3 When the search goes back to S 1 [0] = u 1 The depth at which the 6 When the node set {v 1 ,v 3}Clear.
[0044] In summary, the embodiments of the present invention generate an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure including a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; generate an optimal arrangement of the node set in the query graph using the maximum deleted edge algorithm according to the query graph and the auxiliary structure to obtain an optimal query plan; group nodes with the same successor in the query plan into an equivalence set, and fine-tune the query plan according to the equivalence set; execute the query process according to the fine-tuned query plan to obtain a subgraph matching query result, which can reduce the overhead of the subgraph matching query and can more efficiently process larger-scale query graphs.
[0045] like Figure 5 FIG. 1 is a structural diagram of a subgraph matching query device based on compression of identical successor nodes provided by an embodiment of the present invention, the device comprising:
[0046] An auxiliary structure generation module 501 is used to generate an auxiliary structure corresponding to the query graph according to the query graph and the data graph, wherein the auxiliary structure includes a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge;
[0047] A plan generation module 502 is used to generate an optimal arrangement of the node set in the query graph using a maximum deleted edge algorithm according to the query graph and the auxiliary structure to obtain an optimal query plan;
[0048] A plan fine-tuning module 503, used to classify nodes with the same successor in the query plan into an equivalent set, and fine-tune the query plan according to the equivalent set;
[0049] The matching query module 504 is used to execute the query process according to the fine-tuned query plan to obtain the subgraph matching query result.
[0050] The device of the above embodiment is applied to the corresponding method in the above embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0051] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6As shown, the electronic device may include: a processor (processor) 601, a communication interface (Communications Interface) 602, a memory (memory) 603 and a communication bus 604, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus. The processor may call the logic instructions in the memory to execute a subgraph matching query method based on compression of the same successor node, the method comprising: generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure comprising a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; generating the optimal arrangement of the node set in the query graph using the maximum deletion edge algorithm according to the query graph and the auxiliary structure, and obtaining the optimal query plan; classifying the nodes with the same successor in the query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; executing the query process according to the fine-tuned query plan to obtain the subgraph matching query result.
[0052] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0053] On the other hand, an embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute a subgraph matching query method based on compression of the same successor nodes provided by the above-mentioned method embodiments, the method including: generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure including a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; generating an optimal arrangement of the node set in the query graph using a maximum deletion edge algorithm according to the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with the same successors in the query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; executing the query process according to the fine-tuned query plan to obtain a subgraph matching query result.
[0054] On the other hand, an embodiment of the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute a subgraph matching query method based on compression of identical successor nodes provided in the above-mentioned embodiments, the method comprising: generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph, the auxiliary structure comprising a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; generating an optimal arrangement of the node set in the query graph using a maximum deletion edge algorithm according to the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with identical successors in the query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; executing the query process according to the fine-tuned query plan to obtain a subgraph matching query result.
[0055] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0056] The above is only a partial implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A subgraph matching query method based on compression of identical successor nodes, characterized in that: The method comprises: Generate an auxiliary structure corresponding to the query graph according to the query graph and the data graph, wherein the auxiliary structure includes a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; According to the query graph and the auxiliary structure, a maximum deleted edge algorithm is used to generate an optimal arrangement of the node set in the query graph to obtain an optimal query plan; Classifying nodes with the same successor in the query plan into an equivalence set, and fine-tuning the query plan according to the equivalence set; The query process is executed according to the fine-tuned query plan to obtain the subgraph matching query result.
2. The method according to claim 1, characterized in that The step of generating an auxiliary structure corresponding to the query graph according to the query graph and the data graph includes: Initializing a candidate edge set for each query graph edge in the query graph according to the data graph; False positive candidate edges in each of the candidate edge sets are removed to generate an auxiliary structure corresponding to the query graph.
3. The method according to claim 2, characterized in that Initializing a candidate edge set for each query graph edge in the query graph according to the data graph includes: For any query graph edge (u i ,u j ), if there is a data graph edge (v i ,v j ), query graph node u i The labels and data graph nodes v i The labels are the same, and the query graph node u i The degree is less than or equal to the data graph node v i The degree of the data graph edge (v i ,v j ) is the query graph edge (u i ,u j )’s candidate edges; Scan each edge in the data graph to obtain the query graph edge (u i ,u j ) to obtain the initialized candidate edge set.
4. The method according to claim 2, characterized in that The removing of false positive candidate edges in each of the candidate edge sets to generate an auxiliary structure corresponding to the query graph includes: Considering the candidate edge set of each query graph edge as a relation table; Performing a semi-join process on the relationship table and the relationship tables corresponding to all neighbor edges of the query graph edge, and removing false positive candidate edges in the candidate edge set; This process is repeated multiple times until all false positive candidate edges are filtered out, and an auxiliary structure corresponding to the query graph is generated.
5. The method according to claim 1, characterized in that The fine-tuning of the query plan according to the equivalent set includes: Determine the order of each of the equivalence sets according to the query plan and the arrangement order of the last query graph node in each of the equivalence sets; According to the order of each equivalent set from back to front, move the other nodes except the last query graph node in each equivalent set to the front of the last query graph node, and keep the original node arrangement order unchanged, to obtain the fine-tuned query plan.
6. The method according to claim 1, characterized in that The step of executing the query process according to the fine-tuned query plan to obtain the subgraph matching query result includes: Initialize a corresponding buffer area for caching matching results for each of the equivalent sets; performing a depth-first search according to the fine-tuned query plan; For the current state M of the kth layer, calculate the matching k+1th node u c A node set, where the nodes in the node set are from node u c Selected from the candidate node set, and all matching nodes u c The nodes adjacent to the predecessor neighbor nodes are connected to each node in the node set and node u c Match and get the new next layer state M′; For any equivalence set S, when the search process traces back to the depth of the deepest layer S[-1], the matching node set at this time is cached as the cache key, and S[-1] is the node in the deepest layer of the query plan in the equivalence set S; Each node in the matching node set is rearranged according to the node order in the query plan to obtain a new subgraph matching query result.
7. The method according to claim 6, characterized in that The query process is executed according to the fine-tuned query plan to obtain the subgraph matching query result, and further includes: For an equivalence set, if the search reaches the depth of the deepest node S[-1], the node set that has matched the equivalence set S is put into the cache for query. If it hits, the current branch is pruned, otherwise the search continues; If the current backtracking reaches the depth of the shallowest node S[0], the cache area corresponding to the equivalence set S is cleared.
8. A subgraph matching query device based on compression of identical successor nodes, characterized in that: The device comprises: An auxiliary structure generation module, used to generate an auxiliary structure corresponding to the query graph according to the query graph and the data graph, wherein the auxiliary structure includes a candidate node set corresponding to each query graph node and a candidate edge set corresponding to each query graph edge; A plan generation module is used to generate an optimal arrangement of the node set in the query graph using a maximum deletion edge algorithm according to the query graph and the auxiliary structure to obtain an optimal query plan; A plan fine-tuning module, used for classifying nodes with the same successor in the query plan into an equivalent set, and fine-tuning the query plan according to the equivalent set; The matching query module is used to execute the query process according to the fine-tuned query plan to obtain the subgraph matching query result.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, a subgraph matching query method based on same successor node compression according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a subgraph matching query method based on same successor node compression is implemented as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Method for accelerating accurate sub-graph matching
CN114741565A
Traceability graph compression method and device, electronic equipment and storage medium
CN118568067A
Multi-subgraph matching method and apparatus, and device
US20240095260A1
Subgraph matching device, subgraph matching method, and program
WO2023058151A1