Sub-graph matching method and device

By pruning and cutting large-scale single graphs and decomposing them into sub-query units for matching, the problem of low computational efficiency in existing technologies is solved, and efficient sub-graph matching is achieved on large-scale single graphs.

CN120705356APending Publication Date: 2025-09-26STATE GRID INFORMATION & TELECOMM BRANCH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410313539.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-19
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing subgraph matching algorithms cannot handle large-scale single-graph structures on large-scale stand-alone architectures, and there are problems with a large number of merge operations and invalid query operations, resulting in low computational efficiency.

Method used

By pruning the original data graph, the nodes in the query graph are cut based on the number of occurrences in the pruned data graph to obtain sub-query units, and a graph matching algorithm is used to obtain the matching results of each sub-query unit. Finally, the query result is obtained through a join operation.

Benefits of technology

While ensuring the accuracy of query results, computing efficiency is improved by 50%-300%, especially in the simulation calculation of power grid indicator business-related data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120705356A_ABST
    Figure CN120705356A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of graph calculation, and particularly provides a sub-graph matching method and device, and the method comprises the steps: carrying out the pruning operation of an original data graph based on a query graph, and obtaining a pruned data graph; cutting the query graph based on the occurrence number of nodes in the query graph in the pruned data graph to obtain sub-query units; respectively acquiring a matching result of each sub-query unit on the original data graph by adopting a graph matching algorithm; and performing join operation on the matching result of each sub-query unit on the original data graph to obtain a query result of the query graph on the original data graph. According to the technical scheme provided by the invention, the speed can be increased under the condition of ensuring the accuracy of the query result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of graph computing technology, and in particular to a subgraph matching method and device. Background Art

[0002] Graph mining has widespread applications in various graph computing and graph search fields. Subgraph matching is crucial in both graph computing and graph querying, especially with the rapid development of big data, which is exponentially increasing in data volume and the corresponding expansion of graph structure information. The most important challenge in the current graph computing field is how to efficiently and quickly compute subgraph matching on large-scale single graphs.

[0003] Among existing subgraph matching algorithms, the mainstream technique is depth-first search, which sequentially identifies isomorphic subgraphs for analysis or uses adjacency to identify substructure distances and depth information, performing branch pruning to reduce the search width and achieve subgraph matching. However, with the increasing complexity of business and the surge in data volume, current subgraph matching faces two major challenges: 1. Single-machine architectures are unable to handle large-scale single-graph structures; 2. Single graphs contain a large number of merge operations and invalid queries. Summary of the Invention

[0004] In order to overcome the above-mentioned defects, the present invention proposes a subgraph matching method and device.

[0005] In a first aspect, a subgraph matching method is provided, the subgraph matching method comprising:

[0006] Perform a pruning operation on the original data graph based on the query graph to obtain a pruned data graph;

[0007] Cutting the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units;

[0008] Using a graph matching algorithm to obtain matching results of each sub-query unit on the original data graph;

[0009] A join operation is performed on the matching results of each sub-query unit on the original data graph to obtain the query result of the query graph on the original data graph.

[0010] Preferably, the pruning operation on the original data graph based on the query graph includes:

[0011] When the degree of a node in the original data graph in the query graph is greater than the degree of the node in the original data graph, delete the node in the original data graph;

[0012] When a node in the original data graph is not used in the query graph, the node in the original data graph is deleted.

[0013] Preferably, the slicing of the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph comprises:

[0014] Step a. Calculate the selection probability of each node in the query graph based on the number of occurrences of each node in the data graph after pruning;

[0015] Step b. Select the node with the highest probability in the query graph as the root node of the subquery unit;

[0016] Step c. Connecting the root node of the sub-query unit with its adjacent nodes in the query graph to obtain a sub-query unit;

[0017] Step d. Delete the edges contained in the subquery unit in the query graph. If there are no nodes with a connection relationship, output the obtained subquery unit. Otherwise, use the nodes with a connection relationship as the nodes in the query graph and return to step a.

[0018] Furthermore, the selection probability of each node in the query graph is as follows:

[0019]

[0020] In the above formula, s(v) is the selection probability of node v in the query graph, Deg(v) is the degree of node v in the query graph, and freq(v.tag) is the number of occurrences of node v in the query graph in the data graph after pruning.

[0021] Preferably, performing a join operation on the matching results of each sub-query unit on the original data graph includes:

[0022] Determining a merging coefficient of each sub-query unit based on a matching result of each sub-query unit on the original data graph;

[0023] Based on the merging coefficients of the sub-query units, a join operation is performed on the matching results of the sub-query units on the original data graph in order from small to large.

[0024] Furthermore, the merging coefficients of the sub-query units are as follows:

[0025]

[0026] In the above formula, w is the merging coefficient of the sub-query unit, a is the number of matches of the sub-query unit on the original data graph, and b is the number of nodes in the sub-query unit.

[0027] In a second aspect, a sub-graph matching apparatus is provided, the sub-graph matching apparatus comprising:

[0028] A pruning module is used to prune the original data graph based on the query graph to obtain a pruned data graph;

[0029] A cutting module, configured to cut the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units;

[0030] A matching module, configured to obtain matching results of each sub-query unit on the original data graph using a graph matching algorithm;

[0031] The merging module is used to perform a join operation on the matching results of each sub-query unit on the original data graph to obtain the query result of the query graph on the original data graph.

[0032] In a third aspect, a computer device is provided, comprising: one or more processors;

[0033] The processor is configured to store one or more programs;

[0034] When the one or more programs are executed by the one or more processors, the subgraph matching method is implemented.

[0035] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed, the subgraph matching method is implemented.

[0036] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:

[0037] The present invention provides a subgraph matching method and device, including: performing a pruning operation on an original data graph based on a query graph to obtain a pruned data graph; cutting the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain subquery units; using a graph matching algorithm to obtain the matching results of each subquery unit on the original data graph; and performing a join operation on the matching results of each subquery unit on the original data graph to obtain the query result of the query graph on the original data graph. The technical solution provided by the present invention can achieve speed improvements while ensuring the accuracy of query results. Taking power grid indicator business-related data as an example, a simulated calculation on a large-scale single graph shows that the computational efficiency of the technical solution provided by the present invention can be improved by 50%-300%. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 1 is a schematic flow chart of the main steps of the subgraph matching method according to an embodiment of the present invention;

[0039] Figure 2 is an original data diagram of an embodiment of the present invention;

[0040] Figure 3 is a query graph of an embodiment of the present invention;

[0041] Figure 4 is a pruned data graph according to an embodiment of the present invention;

[0042] Figure 5 2 is a schematic diagram of a query unit set according to an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.

[0044] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0045] As disclosed in the background, graph mining has widespread applications in various graph computing and graph search fields. Subgraph matching is crucial in both graph computing and graph querying, especially with the rapid development of big data, which is exponentially increasing in data volume and the corresponding graph structure information. The most important challenge in the current graph computing field is how to efficiently and quickly compute subgraph matching on large-scale single graphs.

[0046] Among existing subgraph matching algorithms, the mainstream technique is depth-first search, which sequentially identifies isomorphic subgraphs for analysis or uses adjacency to identify substructure distances and depth information, performing branch pruning to reduce the search width and achieve subgraph matching. However, with the increasing complexity of business and the surge in data volume, current subgraph matching faces two major challenges: 1. Single-machine architectures are unable to handle large-scale single-graph structures; 2. Single graphs contain a large number of merge operations and invalid queries.

[0047] In order to improve the above-mentioned problems, the present invention provides a subgraph matching method and device, including: performing a pruning operation on the original data graph based on the query graph to obtain a pruned data graph; cutting the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain subquery units; using a graph matching algorithm to obtain the matching results of each subquery unit on the original data graph; performing a join operation on the matching results of each subquery unit on the original data graph to obtain the query result of the query graph on the original data graph. The technical solution provided by the present invention can achieve speed improvement while ensuring the accuracy of the query results. Taking the data related to the power grid indicator business as an example, the simulation calculation on a large-scale single graph shows that the computational efficiency of the technical solution provided by the present invention can be improved by 50%-300%.

[0048] The above scheme is described in detail below.

[0049] Example 1

[0050] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart showing the main steps of a subgraph matching method according to an embodiment of the present invention. Figure 1 As shown, the subgraph matching method in the embodiment of the present invention mainly includes the following steps:

[0051] Step S101: performing a pruning operation on the original data graph based on the query graph to obtain a pruned data graph;

[0052] Step S102: cutting the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units;

[0053] Step S103: using a graph matching algorithm to obtain matching results of each sub-query unit on the original data graph;

[0054] Step S104: performing a join operation on the matching results of each sub-query unit on the original data graph to obtain a query result of the query graph on the original data graph.

[0055] First, performing graph query on a large-scale single graph is relatively complex. The degree of each vertex in the query graph is compared with the nodes with the same degree of each vertex in the original data graph. The nodes in the data graph whose degree is smaller than the degree of the query graph node are pruned and filtered. At the same time, the nodes in the query graph that do not exist in the original data graph are removed.

[0056] In this embodiment, the pruning operation on the original data graph based on the query graph includes:

[0057] When the degree of a node in the original data graph in the query graph is greater than the degree of the node in the original data graph, delete the node in the original data graph;

[0058] When a node in the original data graph is not used in the query graph, the node in the original data graph is deleted.

[0059] In one embodiment, Figure 2 As shown, the original data graph has six nodes: a, b, c, d, e, and f. At the same time, it can be seen that the degree of each node is {a: 3, b (left): 3, b (right): 4, c: 1, d: 4, e: 1, f: 1}, as shown in Figure 3 As shown, there are five nodes a, b, c, d, and e in the query graph. According to the degree of each node, we know that {a: 2, b: 4, c: 1, d: 2, e: 1}. First, the degree of node b (left) in the query graph is greater than that in the data graph, so node b (left) is invalid in the matching. Node f is not used in the query graph, so the data graph is pruned, as shown in Figure 4 shown.

[0060] When an original data graph has too many nodes, whether it is BFS or DFS, its time complexity and space complexity are very large, and its algorithm cannot be used here. Therefore, the query graph is decomposed into multiple sub-query units for matching. Although the number of steps will increase, the overall complexity will be greatly reduced. The method adopted in the patent of this invention is that, based on the query graph, for the number of nodes that appear in the data graph, the more the number, the less important it is, and the lower its node selectivity; the more adjacent nodes a node has, the more important the node is, and the stronger its node selectivity. According to its data in the data graph and the number of nodes adjacent to it, the selection probability of each node can be calculated, and the root node of its sub-query node can be found according to the selection probability. At the same time, its adjacent nodes are completed in sequence, and finally the node with the largest selection probability is found among the remaining nodes. The above steps are repeated until all the nodes in the query graph are completely cut.

[0061] DFS (Depth-First Search) is an algorithm used to traverse or search a tree or graph. This algorithm searches the branches of the tree as deeply as possible. When all edges to a node v have been explored, the search backtracks to the starting node of the edge that discovered node v. This process continues until all nodes reachable from the source node have been discovered. If any undiscovered nodes remain, one of them is selected as the source node and the above process repeats until all nodes have been visited.

[0062] BFS (Breadth-First Search): A graph search algorithm that finds all nodes starting from a starting node. The algorithm starts at the root node and traverses the tree along the width of the tree, first searching all nodes that are at distance 1 from the root, then at distance 2, and so on.

[0063] In this embodiment, the slicing of the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph includes:

[0064] Step a. Calculate the selection probability of each node in the query graph based on the number of occurrences of each node in the data graph after pruning;

[0065] Step b. Select the node with the highest probability in the query graph as the root node of the subquery unit;

[0066] Step c. Connecting the root node of the sub-query unit with its adjacent nodes in the query graph to obtain a sub-query unit;

[0067] Step d. Delete the edges contained in the subquery unit in the query graph. If there are no nodes with a connection relationship, output the obtained subquery unit. Otherwise, use the nodes with a connection relationship as the nodes in the query graph and return to step a.

[0068] In one embodiment, the selection probability of each node in the query graph is as follows:

[0069]

[0070] In the above formula, s(v) is the selection probability of node v in the query graph, Deg(v) is the degree of node v in the query graph, and freq(v.tag) is the number of occurrences of node v in the query graph in the data graph after pruning.

[0071] In a specific embodiment, according to Figure 3 (Query graph) It can be seen that the degrees of its nodes are: {a: 2, b: 4, c: 1, d: 2, e: 1}, according to Figure 4 After the data graph is pruned, the number of nodes in the query graph can be calculated as: {a: 2, b: 1, c: 1, d: 2, e: 1}. At this time, the node with the largest number is selected as b, and the edges {ba, bc, bd, be} are completed in sequence to obtain the first sub-query unit. At this time, there are only {ac} edges in the query graph, and the adjacent data of nodes a and c are both 1. At this time, a node is randomly selected as the root node of the next sub-query unit, and all nodes in the query graph are allocated. Figure 5 shown.

[0072] For each subquery unit, matching is performed simultaneously on different partitions (this partition refers to the backup partition of the data graph). The matching principles for different subquery units in each partition are as follows: 1. If both nodes of an edge in the subquery unit have been matched, the edge is prioritized. 2. If no match is found, matching is performed from the root node, and then based on the edge's adjacent nodes. Furthermore, the number of adjacent nodes of the node is used as the priority criterion when determining the priority.

[0073] In this embodiment, performing a join operation on the matching results of each sub-query unit on the original data graph includes:

[0074] Determining a merging coefficient of each sub-query unit based on a matching result of each sub-query unit on the original data graph;

[0075] Based on the merging coefficients of the sub-query units, a join operation is performed on the matching results of the sub-query units on the original data graph in order from small to large.

[0076] In one embodiment, the merging coefficients of the sub-query units are as follows:

[0077]

[0078] In the above formula, w is the merging coefficient of the sub-query unit, a is the number of matches of the sub-query unit on the original data graph, and b is the number of nodes in the sub-query unit.

[0079] Example 2

[0080] Based on the same inventive concept, the present invention further provides a sub-graph matching device, the sub-graph matching device comprising:

[0081] A pruning module is used to prune the original data graph based on the query graph to obtain a pruned data graph;

[0082] A cutting module, configured to cut the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units;

[0083] A matching module, configured to obtain matching results of each sub-query unit on the original data graph using a graph matching algorithm;

[0084] The merging module is used to perform a join operation on the matching results of each sub-query unit on the original data graph to obtain the query result of the query graph on the original data graph.

[0085] Preferably, the pruning operation on the original data graph based on the query graph includes:

[0086] When the degree of a node in the original data graph in the query graph is greater than the degree of the node in the original data graph, delete the node in the original data graph;

[0087] When a node in the original data graph is not used in the query graph, the node in the original data graph is deleted.

[0088] Preferably, the slicing of the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph comprises:

[0089] Step a. Calculate the selection probability of each node in the query graph based on the number of occurrences of each node in the data graph after pruning;

[0090] Step b. Select the node with the highest probability in the query graph as the root node of the subquery unit;

[0091] Step c. Connecting the root node of the sub-query unit with its adjacent nodes in the query graph to obtain a sub-query unit;

[0092] Step d. Delete the edges contained in the subquery unit in the query graph. If there are no nodes with a connection relationship, output the obtained subquery unit. Otherwise, use the nodes with a connection relationship as the nodes in the query graph and return to step a.

[0093] Furthermore, the selection probability of each node in the query graph is as follows:

[0094]

[0095] In the above formula, s(v) is the selection probability of node v in the query graph, Deg(v) is the degree of node v in the query graph, and freq(v.tag) is the number of occurrences of node v in the query graph in the data graph after pruning.

[0096] Preferably, performing a join operation on the matching results of each sub-query unit on the original data graph includes:

[0097] Determining a merging coefficient of each sub-query unit based on a matching result of each sub-query unit on the original data graph;

[0098] Based on the merging coefficients of the sub-query units, a join operation is performed on the matching results of the sub-query units on the original data graph in order from small to large.

[0099] Furthermore, the merging coefficients of the sub-query units are as follows:

[0100]

[0101] In the above formula, w is the merging coefficient of the sub-query unit, a is the number of matches of the sub-query unit on the original data graph, and b is the number of nodes in the sub-query unit.

[0102] Example 3

[0103] Based on the same inventive concept, the present invention also provides a computer device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions in the computer storage medium to implement the corresponding method flow or corresponding function, so as to implement the steps of a subgraph matching method in the above embodiment.

[0104] Example 4

[0105] Based on the same inventive concept, the present invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It can be understood that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the steps of a subgraph matching method in the above embodiment.

[0106] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0107] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0108] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0109] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0110] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered by the scope of protection of the claims of the present invention.

Claims

1. A subgraph matching method, characterized in that: The method comprises: Perform a pruning operation on the original data graph based on the query graph to obtain a pruned data graph; Cutting the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units; Using a graph matching algorithm to obtain matching results of each sub-query unit on the original data graph; A join operation is performed on the matching results of each sub-query unit on the original data graph to obtain the query result of the query graph on the original data graph.

2. The method according to claim 1, wherein The pruning operation on the original data graph based on the query graph includes: When the degree of a node in the original data graph in the query graph is greater than the degree of the node in the original data graph, delete the node in the original data graph; When a node in the original data graph is not used in the query graph, the node in the original data graph is deleted.

3. The method according to claim 1, wherein The slicing of the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph includes: Step a. Calculate the selection probability of each node in the query graph based on the number of occurrences of each node in the data graph after pruning; Step b. Select the node with the highest probability in the query graph as the root node of the subquery unit; Step c. Connecting the root node of the sub-query unit with its adjacent nodes in the query graph to obtain a sub-query unit; Step d. Delete the edges contained in the subquery unit in the query graph. If there are no nodes with a connection relationship, output the obtained subquery unit. Otherwise, use the nodes with a connection relationship as the nodes in the query graph and return to step a.

4. The method according to claim 3, wherein The selection probability of each node in the query graph is as follows: In the above formula, s(v) is the selection probability of node v in the query graph, Deg(v) is the degree of node v in the query graph, and freq(v.tag) is the number of occurrences of node v in the query graph in the data graph after pruning.

5. The method according to claim 1, wherein The performing a join operation on the matching results of each sub-query unit on the original data graph includes: Determining a merging coefficient of each sub-query unit based on a matching result of each sub-query unit on the original data graph; Based on the merging coefficients of the sub-query units, a join operation is performed on the matching results of the sub-query units on the original data graph in order from small to large.

6. The method according to claim 5, wherein The merging coefficients of the sub-query units are as follows: In the above formula, w is the merging coefficient of the sub-query unit, a is the number of matches of the sub-query unit on the original data graph, and b is the number of nodes in the sub-query unit.

7. A device based on the subgraph matching method according to any one of claims 1 to 6, characterized in that: The device comprises: A pruning module is used to prune the original data graph based on the query graph to obtain a pruned data graph; A cutting module, configured to cut the query graph based on the number of occurrences of nodes in the query graph in the pruned data graph to obtain sub-query units; A matching module, configured to obtain matching results of each sub-query unit on the original data graph using a graph matching algorithm; The merging module is used to perform a join operation on the matching results of each sub-query unit on the original data graph to obtain the query result of the query graph on the original data graph.

8. A computer device, characterized in that: include: one or more processors; The processor is configured to execute one or more programs; When the one or more programs are executed by the one or more processors, the subgraph matching method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is executed, the sub-graph matching method according to any one of claims 1 to 6 is implemented.