Subgraph matching query method and device based on compression of identical successor nodes

By generating auxiliary structures and equivalent set micro-inquiry query plans, the problem of high complexity of sub-graph matching query is solved, and efficient processing of large-scale query graphs is achieved.

CN119537653BActive Publication Date: 2025-08-26NAT UNIV OF DEFENSE TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411683737.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-08-26
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

In the prior art, with the increase of the number of query graph nodes, the complexity of the sub-graph matching query increases rapidly like an exponential explosion, resulting in high query complexity and long-term consumption, and a more efficient compression algorithm is needed to reduce the search complexity.

Method used

By generating auxiliary structures corresponding to the query graph, the maximum delete edge algorithm is used to generate the optimal query plan, the nodes with the same successor are classified into equivalent sets, and the query plan is fine-tuned, and the sub-graph matching query results are obtained by combining the depth-first search algorithm.

Benefits of technology

It effectively reduces the overhead of sub-graph matching queries, can efficiently process larger-scale query graphs, and improves query efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119537653B_ABST
    Figure CN119537653B_ABST
Patent Text Reader

Abstract

The present application provides a subgraph matching query method and apparatus based on compression of identical successor nodes, comprising: generating an auxiliary structure corresponding to the query graph based on 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 edge deletion algorithm based on the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with identical successors in the query plan into an equivalence set, and fine-tuning the query plan based on the equivalence set; executing the query process based on the fine-tuned query plan to obtain a subgraph matching query result. This method can reduce the overhead of subgraph matching queries and enable more efficient processing of larger-scale query graphs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of subgraph matching technology, and in particular relates 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. Such queries are highly complex and time-consuming, requiring more efficient algorithms for optimization. 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 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 as the number of query graph nodes increases, 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 search complexity 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 based on 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 based on a 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 equivalence set, and fine-tuning the query plan based on the equivalence set; executing the query process based on 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 one 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 and 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 relational table; semi-joining the relational table with the relational 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 other nodes except 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, each node in the node set is connected to the node u c Matching is performed to obtain a new next-level 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 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 for query. 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 corresponding to the equivalence set S is cleared.

[0012] In the 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 based on 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 deletion edge algorithm based on the query graph and the auxiliary structure, to obtain 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 based on the equivalent set; a matching query module for executing a query process based on the fine-tuned query plan to obtain 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. 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 following briefly introduces the drawings required for describing the embodiments of the present application.

[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 one embodiment of the present invention;

[0018] Figure 3 A schematic diagram of a depth-first search provided by one embodiment of the present invention;

[0019] Figure 4 A schematic diagram of query plan fine-tuning provided by one 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 This is a schematic diagram of the physical structure of an electronic device provided by the present invention.

[0022] Specific implementation method

[0023] The following describes embodiments of the present application in detail. 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 having 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 are not to be construed as limiting the present invention.

[0024] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of this 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 module, or there may be an intermediate module. In addition, "connected" or "coupled" as 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 this application clearer, the implementation of this application will be further described in detail below with reference to the accompanying drawings.

[0026] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. 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 FIG2 is a flowchart of a subgraph matching query method based on compression of identical successor nodes provided by one embodiment of the present invention. The method includes:

[0028] Step S11 : generating 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.

[0029] Step S12: generating 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, 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 search process.

[0031] Step S13: Group the nodes with the same successor in the query plan into an equivalence set, and fine-tune the query plan according to the equivalence set.

[0032] Step S14: execute 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, which can obtain an equivalent set according to the 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 and 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 the auxiliary structure corresponding to the query graph. i ,u j ) is considered as a relation table R(u i ,u j ); the relation table R(u i ,u j ) and query graph edge (u i ,u j ) Perform semi-join processing on the relationship tables corresponding to all neighbor edges, and remove the false positive candidate edges in the candidate edge set; repeat several times until the filtered relationship table R(u i ,u j ) to generate the 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 candidate node set of the query graph node u0 is Including data graph nodes v0, v1 and v2, query graph node u1 candidate node set Including data graph nodes v3 and v4, query graph node u2 candidate node set Including data graph nodes v5 and v6, query graph node u3 candidate node set Including data graph nodes v9...v 100 , query the candidate node set of graph node u4 Including data graph nodes v0, u1 and v2, query graph node u5 candidate node set Includes data graph nodes u7 and v8.

[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, which are called the predecessor neighbors of the query graph node u and are denoted as N + (u), the other part is the neighbors that are located after the query graph node u in the search order, which are called the successor neighbors of the query graph node u and are recorded as N - (u). Nodes with the same successor neighbors are grouped into an equivalent set S, i.e. N - (u1)-S=N - (u2)-S, e.g. Figure 3 In the example, u1 and u3 belong to the same equivalence set because their successor neighbors are the same, i.e., {u3,u4}-{u1,u3}={u4}-{u1,u3}.

[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, determine the order of each equivalence set according to the order of the last query graph node in each equivalence set according to the query plan. For each equivalence set S, S[-1] is recorded as the order according to the plan. Arrange the last node in S in the order of S[-1], which is the last node searched in S. Sort all equivalent sets and arrange them in the order of S[-1]. For example Figure 4 Assume that there are two equivalent sets S1 = {u1, u3} and S2 = {u0, u2, u5}, marked with the same filling pattern. Their last nodes are S1[-1] = u3 and S2[-1] = u5 respectively. Therefore, after sorting, the equivalent set S1 is arranged before the equivalent set S2.

[0038] Then, according to the order between the 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, all nodes except the last query graph node in each equivalent set are moved to the front of the last query graph node, and the original node arrangement order is kept unchanged to obtain the fine-tuned query plan. Specifically, first process the set equivalent set S2, move all other nodes in the equivalent set S2 to the front of S2[-1]=u5, and keep the original relative order, so as to obtain the new plan. Then do the same operation on S1 and you can get the final plan Following this process from back to front, we can ensure that the equivalence relation within each equivalence set is not destroyed. For example Figure 4 , nodes with the same fill pattern indicate that they belong to the same equivalence set, such as in the initial plan In the plan, u2 and u5 belong to the same equivalence set. Move node u2 from the third position to before the position of u5. In this way, the nodes in this equivalence set are in the new plan. The same operation is performed on other equivalent sets, and finally a fine-tuned plan is obtained. The nodes in the same equivalence set are arranged together and their subsequent 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, each node in the node set is connected to the node u c Match 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 node that can match the k+1th node in the plan. The node set C(u c ), these nodes are from the auxiliary structure in 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] Applying Cache 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 backtracks to the depth of the deepest level 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 3For the equivalence set S1=u1,u3, S1[0]=u1, S1[-1]=u3, when the search process traces back to the depth of the deepest node S1[-1], the matching equivalent node set at this time is cached as the cache key. In this example, the corresponding matching equivalent node set {v1,v3} is cached as the key.

[0041] Then, the found results are rearranged. After caching the matching equivalent node sets v1 and v3, these nodes are rearranged to obtain new results. That is, each node in the matching equivalent node set is rearranged according to all possibilities to obtain a new subgraph matching query result. Figure 3 When backtracking to state M4, assuming that the search returns a matching result {u0:v0,u2:v2,u1:v3,u3:v1,u4:v4,u5:v5}, then the matching results of the equivalent set S1={u1,u3} are rearranged to obtain a new matching result {u0:v0,u2:v2,u1:v1,u3:v3,u4:v4,u5:v5}, that is, the matching nodes u1 and u3 are exchanged. For this matching result, it is also necessary to verify whether it is isomorphic. If so, it is output as the result, otherwise it is directly filtered out.

[0042] In this embodiment of the present invention, if a cache hit is found during the subsequent search, the current redundant branch is deleted. For an equivalence set, if the forward search reaches the depth of the deepest node S[-1], the node set that matches the equivalence set S is placed in the cache for query. If a hit is found, it means that all results under the current branch have been output through the previous reordering 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 backtracking reaches the depth of the shallowest node S[0], the cache area corresponding to the equivalence set S is cleared. For example Figure 3 In the example, when the search traces back to the depth where S1[0]=u1, that is, back to M6, the node set {v1, v3} previously cached in the cache is cleared.

[0044] In summary, the embodiments of the present invention generate an auxiliary structure corresponding to the query graph based on 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; based on the query graph and the auxiliary structure, a maximum deletion edge algorithm is used to generate an optimal arrangement of the node set in the query graph to obtain an optimal query plan; nodes with the same successor in the query plan are grouped into an equivalence set, and the query plan is fine-tuned according to the equivalence set; the query process is executed 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 one embodiment of the present invention, the device comprising:

[0046] An auxiliary structure generation module 501 is configured to generate an auxiliary structure corresponding to the query graph based on 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 configured to generate an optimal arrangement of the node set in the query graph using a maximum deleted edge algorithm based on the query graph and the auxiliary structure to obtain an optimal query plan;

[0048] A plan fine-tuning module 503 is configured to group nodes with the same successor in a query plan into an equivalence set and fine-tune the query plan based on the equivalence 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 apparatus of the above embodiment is applied to the corresponding method of 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 below. 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 communicate with each other via the communication bus. The processor can call logic instructions in the memory to execute a subgraph matching query method based on compression of identical successor nodes, the method comprising: generating an auxiliary structure corresponding to the query graph based on 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 based on the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with identical successors in the query plan into an equivalence set, and fine-tuning the query plan based on the equivalence set; executing a query process based on the fine-tuned query plan to obtain a subgraph matching query result.

[0052] In addition, the logical instructions in the above-mentioned memory can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, 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. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0053] On the other hand, an embodiment of the present invention also 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 based on 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; using the maximum deletion edge algorithm to generate the optimal arrangement of the node set in the query graph based on the query graph and the auxiliary structure to obtain the optimal query plan; classifying 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; executing the query process according to the fine-tuned query plan to obtain the 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 based on the query graph and the data graph, the auxiliary structure comprising a set of candidate nodes corresponding to each query graph node and a set of candidate edges corresponding to each query graph edge; generating an optimal arrangement of the set of nodes in the query graph using a maximum deletion edge algorithm based on the query graph and the auxiliary structure to obtain an optimal query plan; grouping nodes with identical successors in the query plan into an equivalence set, and fine-tuning the query plan based on the equivalence 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 flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed 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 some of the steps in the flowcharts 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 portion 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: generating 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; Generating 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; 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; Execute the query process according to the fine-tuned query plan to obtain the subgraph matching query result; The step of generating an auxiliary structure corresponding to the query graph based on 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; removing false positive candidate edges from each of the candidate edge sets to generate an auxiliary structure corresponding to the query graph; The step of 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 in the query graph , if there is a data graph edge in the data graph , query graph nodes Labels and data graph nodes The labels are the same, and the query graph node The degree is less than or equal to the data graph node The degree of the data graph is determined For the query graph edge Candidate edges of Scan each edge in the data graph to obtain the query graph edge All candidate edges of , get the initialized candidate edge set; Wherein, fine-tuning the query plan according to the equivalence set includes: Determining 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 equivalence set from back to front, the other nodes except the last query graph node in each equivalence set are moved to the front of the last query graph node, and the original node arrangement order is kept unchanged to obtain the fine-tuned query plan.

2. The method according to claim 1, wherein The removing of false positive candidate edges from each of the candidate edge sets to generate an auxiliary structure corresponding to the query graph includes: Treating 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; Repeat multiple times until all false positive candidate edges are filtered out, and an auxiliary structure corresponding to the query graph is generated.

3. The method according to claim 1, wherein The step of executing the query process according to the fine-tuned query plan to obtain the subgraph matching query result includes: Initializing a corresponding buffer area for caching matching results for each of the equivalence sets; performing a depth-first search according to the fine-tuned query plan; For the current Layer status , calculate the matching nodes A node set, where the nodes in the node set are slave nodes Selected from the candidate node set, and all matching nodes The nodes adjacent to the predecessor neighbor nodes are connected to each node in the node set. Match and get the new next layer state ; For any equivalent set , when the search process goes back to the deepest level When the depth is reached, the matching node set is cached as the cache key. For the equivalent set The node at the deepest level of the query plan; 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.

4. The method according to claim 3, wherein The query process is executed according to the fine-tuned query plan to obtain the subgraph matching query result, and further includes: For an equivalent set, if the deepest node is found when searching forward At the depth of The node set 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 shallowest node The depth at which The corresponding buffer area is cleared.

5. A subgraph matching query device based on compression of identical successor nodes, characterized in that: The device comprises: An auxiliary structure generation module, configured to generate an auxiliary structure corresponding to the query graph based on 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; The plan generation module is used to generate the optimal arrangement of the node set in the query graph using the maximum deletion edge algorithm based on the query graph and the auxiliary structure to obtain the optimal query plan; A plan fine-tuning module, configured to 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; A matching query module, configured to execute a query process according to the fine-tuned query plan and obtain a subgraph matching query result; The step of generating an auxiliary structure corresponding to the query graph based on 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; removing false positive candidate edges from each of the candidate edge sets to generate an auxiliary structure corresponding to the query graph; The step of 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 in the query graph , if there is a data graph edge in the data graph , query graph nodes Labels and data graph nodes The labels are the same, and the query graph node The degree is less than or equal to the data graph node The degree of the data graph is determined For the query graph edge Candidate edges of Scan each edge in the data graph to obtain the query graph edge All candidate edges of , get the initialized candidate edge set; Wherein, fine-tuning the query plan according to the equivalent set includes: Determining 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 equivalence set from back to front, the other nodes except the last query graph node in each equivalence set are moved to the front of the last query graph node, and the original node arrangement order is kept unchanged to obtain the fine-tuned query plan.

6. An electronic device 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, the subgraph matching query method based on same successor node compression according to any one of claims 1 to 4 is implemented.

7. 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, the computer program implements a subgraph matching query method based on same successor node compression according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for accelerating accurate sub-graph matching

    CN114741565A

  • Traceability graph compression method and device, electronic equipment and storage medium

    CN118568067A