Subgraph matching method and apparatus
By calculating the graph structure of query graphs and data graphs, determining the node matching order, the problem of low sub-graph matching efficiency in the prior art is solved, and a more efficient sub-graph matching process is achieved.
Patent Information
- Application Number
- PCT/CN2024/120271
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-28
- Filing Date
- 2024-09-23
- Publication Date
- 2025-04-03
AI Technical Summary
The existing subgraph matching algorithm has high randomness when the search order of the starting node of the query graph is determined, resulting in uncertainty in the search space and low matching efficiency.
By calculating the graph structure of the query graph and the data graph, the selection degree of each node is calculated, and the node matching order of the query graph is determined, so as to efficiently match sub-graphs in the data graph.
It significantly improves the matching efficiency of sub-graph matching, reduces the search space, and enhances the accuracy of matching results.
Smart Images

Figure CN2024120271_03042025_PF_FP_ABST
Abstract
Description
A subgraph matching method and device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on September 28, 2023, with application number 202311292325.7 and application name “A Subgraph Matching Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of computers, and in particular to a subgraph matching method and apparatus. Background Art
[0003] Subgraph matching is a key research topic in graph analytics. It involves matching a given query graph on a larger data graph to obtain all subgraphs with the same structure as the query graph. Subgraph matching has applications in social network analysis, bioinformatics, transportation, group discovery, anomaly detection, and other fields.
[0004] In the current subgraph matching algorithm, when the computing device performs subgraph matching on the query graph, the computing device needs to search the nodes in the query graph. When determining the search order of the nodes in the query graph, the computing device often randomly determines a node as the starting node of the query graph search. Since the random determination of the starting node of the query graph search will lead to uncertainty in the search space, the matching efficiency of the subgraph matching is relatively low.
[0005] Summary of the Invention
[0006] Embodiments of the present application provide a subgraph matching method in which a computing device, when performing subgraph matching, can determine the node matching order for a query graph search based on the graph structures of the query graph and the data graph, thereby improving the efficiency of subgraph matching. Embodiments of the present application also provide a subgraph matching apparatus, computing device, computing device cluster, computer-readable storage medium, and computer program product corresponding to the subgraph matching method.
[0007] In the first aspect, an embodiment of the present application provides a message processing method based on tunneling technology, which can be executed by a subgraph matching system, or by a component of the subgraph matching system, such as a processor, chip or chip system of the subgraph matching system, or by a logic module or software that can realize all or part of the functions of the subgraph matching system. The method provided in the first aspect includes: the subgraph matching system obtains a query graph and a data graph, and the query graph is used to perform subgraph matching in the data graph. The node matching order of the query graph is determined based on the graph structure of the query graph and the graph structure of the data graph, the node matching order is used to indicate the node order for subgraph matching in the query graph, the graph structure of the data graph is used to calculate the selectivity of the nodes in the query graph, and the selectivity is used to determine the starting node of the node matching order. Subgraph matching is performed in the data graph based on the node matching order, and a matching result is generated. The matching result includes one or more subgraphs in the data graph that have the same graph structure as the query graph.
[0008] In the embodiment of the present application, the subgraph matching system can calculate the selectivity of each node in the query graph based on the graph structure of the query graph and the graph structure of the data graph, and determine the starting matching node and the node matching order of the query graph based on the selectivity. Compared with the current method in which the computing device randomly determines the starting matching node during the subgraph matching process, the subgraph matching method provided in the embodiment of the present application improves the subgraph matching efficiency of the query graph.
[0009] In one possible implementation, the query graph includes one or more of the following: an undirected graph, a directed graph, an attributed graph, and an attributeless graph. An undirected graph is a graph in which the edges have no direction. A directed graph is a graph in which the edges have direction, and the edges of a directed graph also indicate the direction connecting one node to another. An attributed graph is a query graph that contains not only nodes and edges but also attribute information of the nodes and edges. An attributeless graph is a graph structure that lacks attribute information of nodes or edges.
[0010] The subgraph matching method provided in the embodiments of the present application can be applied to subgraph matching of query graphs of various graph structures, thereby improving the scope of application of the subgraph matching method of the present application.
[0011] In one possible implementation, the user can input the query graph through the display interface of the subgraph matching system, or provide the description information of the query graph to the subgraph matching system by uploading a file. The description information of the query graph includes the node attributes and edge relationships of the query graph.
[0012] In the embodiment of the present application, the subgraph matching system can obtain the query graph for subgraph matching in a variety of ways, thereby improving the feasibility of the subgraph matching solution.
[0013] In one possible implementation, while determining the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph, the subgraph matching system calculates the selectivity of each node in the query graph. The selectivity is the number of nodes in the data graph that contain a connection relationship with the node. The subgraph matching system determines a matching starting node based on the selectivity of the node in the query graph. The matching starting node is the node with the lowest selectivity in the query graph. The subgraph matching system further determines a matching node after the matching starting node based on the number of edges connecting the remaining nodes in the query graph. The matching node is the node with the largest number of edges among the remaining nodes in the query graph.
[0014] In the embodiment of the present application, the subgraph matching system can calculate the number of connection relationships of each node in the query graph that appear in the data graph, obtain the selectivity of each node, and use the node with the smallest selectivity as the starting matching node in the node matching order, thereby improving the matching efficiency of the subgraph matching.
[0015] In one possible implementation, when the number of connected edges of the remaining nodes in the query graph is the same, the matching node after the matching starting node is determined based on the selectivity of the remaining nodes. Specifically, the subgraph matching system selects the node with the smallest selectivity among the remaining nodes as the matching node after the matching starting node.
[0016] In an embodiment of the present application, when the number of connection edges of the remaining nodes in the query graph is the same, the subgraph matching system can determine the matching nodes after the matching start node based on the selectivity of the remaining nodes, thereby improving the matching efficiency of the subgraph matching.
[0017] In one possible implementation, the subgraph matching system identifies equivalent points based on the query graph. Specifically, after the subgraph matching system swaps the mappings of two nodes, if the query graph structure remains unchanged, the two nodes are considered equivalent. If the nodes are unidirectionally connected, the equivalent points form an equivalence ring.
[0018] In the embodiment of the present application, the subgraph matching system can identify equivalent nodes in the query graph, so as to constrain the equivalent nodes, thereby improving the feasibility of determining equivalent constraint relationships.
[0019] In one possible implementation, before the subgraph matching system determines a node matching order for the query graph based on the graph structure of the query graph and the graph structure of the data graph, the subgraph matching system determines an equivalence constraint relationship based on the query graph. The equivalence constraint relationship is used to determine a matching range for subgraph matching in the data graph, and the subgraphs within the matching range satisfy the equivalence constraint relationship. The subgraph matching system performs subgraph matching in the data graph based on the node matching order, including performing subgraph matching within the matching range in the data graph based on the node matching order.
[0020] In the embodiment of the present application, the subgraph matching system can prune the search range of the data graph by setting an equivalent constraint relationship, avoid matching equivalent subgraphs, and thus improve the matching efficiency of subgraph matching.
[0021] In one possible implementation, in the process of determining the equivalence constraint relationship based on the query graph in the subgraph matching system, the subgraph matching system determines the equivalence constraint relationship based on the node identifiers of the query graph, and the equivalence constraint relationship includes an ascending arrangement of the node identifiers or a descending arrangement of the node identifiers of the nodes in the query graph.
[0022] In the embodiment of the present application, the subgraph matching system can set an equivalent constraint relationship based on the node identifier in the query graph, so that the subgraph satisfies the constraint of the node identifier during the subgraph matching process, thereby reducing the matching scope of the subgraph matching and improving the matching efficiency of the subgraph matching.
[0023] In one possible implementation, the subgraph matching system searches the data graph for nodes in the query graph in the node matching order based on a parallel search strategy. The parallel search strategy includes breadth-first search and depth-first search. Breadth-first search begins at a starting node and expands outward layer by layer, first visiting all adjacent nodes of the starting node and then visiting their adjacent nodes. Depth-first search begins at a starting node and traverses along the edges of the graph until it reaches a node where it cannot proceed any further, then backtracks to the nearest unvisited node and continues its exploration.
[0024] In the embodiment of the present application, the subgraph matching system can search for nodes in the query graph based on a parallel search strategy, thereby improving the subgraph matching efficiency of the query graph.
[0025] In one possible implementation, the subgraph matching system determines the number of depth-first search steps based on the estimated memory consumption, and the estimated memory consumption is used to indicate the memory occupied by the search results of the breadth-first search that is parallel to the depth-first search steps. Since in depth-first search, each thread performs a complete search task, depth-first search can save memory. In breadth-first search, after each node is matched, all current intermediate matching results are collected and redistributed, which can improve parallelism, but it takes up more memory. The subgraph matching system predicts the memory occupied by the search results of the breadth-first search that is parallel to the depth-first search steps, and determines the number of depth-first search steps corresponding to the predicted memory being less than a threshold. When the subgraph matching system performs subgraph matching according to the number of depth-first search steps, the memory consumption of the breadth-first search will not exceed the memory threshold.
[0026] In an embodiment of the present application, the subgraph matching system can determine the number of search steps of the depth-first search based on the estimated memory consumption of the search results of the breadth-first search, thereby reducing the number of search results of the breadth-first search and reducing the memory consumption of the subgraph matching process.
[0027] The second aspect of the embodiment of the present application provides a subgraph matching device, which includes an acquisition unit, a sorting unit and a matching unit. The acquisition unit is used to acquire a query graph and a data graph, and the query graph is used to perform subgraph matching in the data graph. The sorting unit is used to determine the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph. The node matching order is used to indicate the node order for subgraph matching in the query graph. The graph structure of the data graph is used to calculate the selectivity of the nodes in the query graph, and the selectivity is used to determine the starting node of the node matching order. The matching unit is used to perform subgraph matching in the data graph based on the node matching order and generate a matching result. The matching result includes one or more subgraphs in the data graph that have the same graph structure as the query graph.
[0028] In one possible implementation, the query graph includes one or more of the following: an undirected graph, a directed graph, an attributed graph, and an attributeless graph.
[0029] In one possible implementation, the sorting unit is specifically configured to calculate the selectivity of each node in the query graph, where the selectivity is the number of nodes in the data graph that contain a connection relationship with the node. A matching starting node is determined based on the selectivity, with the matching starting node being the node with the lowest selectivity in the query graph. A matching node after the matching starting node is determined based on the number of edges connecting the remaining nodes in the query graph, with the matching node being the node with the largest number of edges connecting the remaining nodes in the query graph.
[0030] In a possible implementation, the sorting unit is further configured to determine a matching node after the matching start node according to the selectivity of the remaining nodes when the number of connection edges of the remaining nodes in the query graph is the same.
[0031] In one possible embodiment, the apparatus further includes a constraint unit configured to determine an equivalence constraint relationship based on the query graph. The equivalence constraint relationship is used to determine a matching range within the data graph for performing subgraph matching, wherein the subgraphs within the matching range satisfy the equivalence constraint relationship. The matching unit is specifically configured to perform subgraph matching within the matching range within the data graph based on a node matching order.
[0032] In a possible implementation, the constraint unit is specifically configured to determine an equivalence constraint relationship based on node identifiers of the query graph, where the equivalence constraint relationship includes ascending or descending arrangement of node identifiers of the nodes in the query graph.
[0033] In a possible implementation, the matching unit is specifically configured to search the data graph for nodes in the query graph in a node matching order based on a parallel search strategy, where the parallel search strategy includes a breadth-first search and a depth-first search.
[0034] In one possible implementation, the matching unit is further configured to determine the number of depth-first search steps based on estimated memory consumption, where the estimated memory consumption indicates the memory occupied by search results of a breadth-first search performed in parallel with the depth-first search steps.
[0035] A third aspect of an embodiment of the present application provides a computing device, comprising a processor coupled to a memory, the processor being used to store instructions. When the instructions are executed by the processor, the computing device executes the method described in the first aspect or any possible implementation of the first aspect.
[0036] A fourth aspect of an embodiment of the present application provides a computing device cluster, which includes one or more computing devices. The computing device includes a processor, which is coupled to a memory. The processor is used to store instructions. When the instructions are executed by the processor, the computing device cluster executes the method described in the first aspect or any possible implementation method of the first aspect.
[0037] A fifth aspect of the embodiments of the present application provides a computer-readable storage medium having instructions stored thereon. When the instructions are executed, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0038] A sixth aspect of the embodiments of the present application provides a computer program product, which includes instructions. When the instructions are executed, the computer implements the method described in the first aspect or any possible implementation method of the first aspect.
[0039] It can be understood that the beneficial effects that can be achieved by any of the sub-graph matching devices, computing devices, computing device clusters, computer-readable media or computer program products provided above can refer to the beneficial effects in the corresponding methods and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] FIG1 is a schematic diagram of the system architecture of a subgraph matching system provided in an embodiment of the present application;
[0041] FIG2 is a schematic diagram of a flow chart of a subgraph matching method provided in an embodiment of the present application;
[0042] FIG3a is a schematic diagram of a flow chart of another subgraph matching method provided in an embodiment of the present application;
[0043] FIG3 b is a schematic diagram of a query graph type provided by an embodiment of the present application;
[0044] FIG4 is a schematic diagram of determining a node matching order according to an embodiment of the present application;
[0045] FIG5 is a schematic diagram of an equivalent constraint relationship provided in an embodiment of the present application;
[0046] FIG6 is a schematic diagram of a parallel search strategy provided in an embodiment of the present application;
[0047] FIG7 is a schematic structural diagram of a sub-graph matching device provided in an embodiment of the present application;
[0048] FIG8 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0049] FIG9 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The embodiments of the present application provide a subgraph matching method and apparatus for improving the matching efficiency of subgraph matching.
[0051] The terms "first," "second," "third," "fourth," and the like (if any) in the specification and claims of this application and in the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequential sequence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] In the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of this application should not be interpreted as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0053] First, some terms involved in the embodiments of the present application are introduced to facilitate those skilled in the art to understand the technical solutions.
[0054] Subgraph matching is to find a subgraph in a given large graph that is isomorphic to a given small graph. Subgraph matching is a basic graph query operation that aims to discover important substructures in the graph.
[0055] Graph isomorphism means that given two graphs G1 = (V1, E1) and G2 = (V2, E2), if there exists a bijective function f: V(G1) → V(G2), such that for Graphs G1 and G2 are said to be isomorphic if and only if e2 = (f(vi), f(vj))∈E2 and e1 and e2 have the same multiplicity.
[0056] An equivalent point refers to two nodes vi,vj∈G=(V,E) in a given graph. If there exists a bijective function f:V(G)→V(G),f(vi)=vj,f(vj)=vi,f(vk)=vk,k≠i,j, such that f(G) is isomorphic to G, then vi and vj are called equivalent points in the graph G.
[0057] Selectivity is the degree of selection in the specified query graph P = (V1, E1) and data graph G = (V2, E2). After matching vj∈G according to the in-and-out degree conditions vj.indeg ≥ vi.indeg AND vj.outdeg ≥ vi.outdeg, the size of the point set mapped in the data graph G is called the selectivity of the point in the query graph P under the real graph G. The selectivity reflects the size of the possible candidate set of the node in the query graph in the data graph.
[0058] In order to make the technical solution of the present application clearer and easier to understand, the system architecture of the present application is introduced below with reference to the accompanying drawings.
[0059] Please refer to Figure 1, which is a schematic diagram of the system architecture for subgraph matching provided in the example of this application. In the example shown in Figure 1, the subgraph matching system 10 includes a software layer 100 and a hardware layer 200. The software layer 100 includes a graph data reading module 101, an equivalent point constraint module 102, a mining plan generation module 103, and a dynamic search and matching module 104. The hardware layer 200 includes one or more computing devices 201. Multiple computing devices 201 can constitute a distributed subgraph matching system. The functions of each component of the subgraph matching system 10 are described in detail below.
[0060] Software layer 100 implements the software portion of the subgraph matching system, including storage and management of graph data and providing a subgraph matching algorithm. Software layer 100 includes a graph data reading module 101, an equivalent point constraint module 102, a mining plan generation module 103, and a dynamic search and matching module 104.
[0061] The graph data reading module 101 is used to read the data graph and the query graph. For example, the graph data reading module 101 can export the data graph from a database or generate the data graph based on comma-separated values (CSV) data. The query graph is the subgraph on which the subgraph matching system 10 will perform subgraph matching, and the data graph is the original graph on which the query graph search is to be performed.
[0062] The equivalent point constraint module 102 is used to generate equivalent constraints corresponding to the query graph. Equivalent point constraints are used to prune the data graph. Equivalent points are nodes in the query graph that can be interchanged without changing the graph structure. By constraining equivalent points in the query graph, the equivalent point constraint module 102 can avoid matching equivalent graphs of multiple query graphs during subgraph matching.
[0063] The mining plan generation module 103 is used to determine the node matching order for subgraph matching. Specifically, the mining plan generation module 103 is used to calculate the selectivity of each node in the query graph in the data graph and determine the starting node for subgraph matching based on the selectivity. After the mining plan generation module 103 determines the starting node for subgraph matching, it determines the matching nodes after the starting node based on the number of connected edges of the remaining nodes, thereby determining the node matching order for subgraph matching.
[0064] The dynamic search and matching module 104 is configured to search the data graph for nodes in the query graph in a node matching order based on a parallel search strategy to obtain a subgraph corresponding to the query graph. Parallel search strategies include depth-first search and breadth-first search. The dynamic search and matching module 104 is further configured to determine the number of depth-first search steps based on estimated memory consumption, where the estimated memory consumption is the memory occupied by the search results of the breadth-first search performed in parallel with the depth-first search steps.
[0065] The hardware layer 200 is used to provide the hardware devices of the subgraph matching system, and the various modules in the software layer 100 are deployed in the hardware devices in the hardware layer 200. The hardware devices in the hardware layer 200 include one or more computing devices 201. Multiple computing devices 201 can form a distributed subgraph matching system architecture.
[0066] It is understandable that the computing device 201 in the embodiment of the present application can be a cloud server, a local server or a personal computer, without specific limitation.
[0067] Based on the sub-graph matching system 10 shown in Figure 1 , the present application further provides a sub-graph matching method. The sub-graph matching method provided in the present application is described below in conjunction with an embodiment.
[0068] Please refer to Figure 2, which is a flow chart of a method for converting a network address provided in an embodiment of the present application. In the example shown in Figure 2, the method includes the following steps:
[0069] 201. The subgraph matching system obtains a query graph and a data graph, and the query graph is used to perform subgraph matching in the data graph.
[0070] The subgraph matching system 10 obtains a query graph and a data graph. The query graph is used to perform subgraph matching within the data graph. Specifically, the subgraph matching system 10 receives a query graph provided by a user. For example, the user may enter the query graph through the display interface of the subgraph matching system 10 or upload a file to provide the subgraph matching system 10 with a description of the query graph. The query graph description includes node attributes and edge relationships of the query graph.
[0071] The query graph in the embodiments of the present application includes one or more of the following graph structures: an undirected graph, a directed graph, an attributed graph, and an unattributed graph. An undirected graph is a graph in which the edges have no direction. In an undirected graph, an edge can go from one node to another without regard to any directionality. An undirected graph can be represented as a set of nodes and edges, where edges represent the connection between nodes but do not specify a direction.
[0072] A directed graph is one in which the edges are oriented. The edges of a directed graph also indicate the direction from one node to another. In a directed graph, paths from one node to another can only follow the directions of the edges. A directed graph can also be represented as a set of nodes and edges, but the edges represent directed relationships between nodes.
[0073] A property graph refers to a query graph that contains not only nodes and edges but also attribute information about those nodes and edges. Node attributes are properties or characteristics associated with each node in the graph, while edge attributes are properties or characteristics associated with each edge in the graph. Property graphs can be used to indicate additional attribute information about nodes and edges. Non-attributed graphs are graph structures that lack attribute information about nodes or edges. Non-attributed graphs contain only the connections between nodes and edges, without any attribute information about those nodes or edges. In other words, non-attributed graphs simply represent the topological structure between nodes and edges.
[0074] It should be noted that there is no correlation between the attributes and directions of the query graph, that is, the attribute graph can be either an undirected graph or a directed graph, and the non-attribute graph can be either a directed graph or an undirected graph.
[0075] Please refer to Figure 3a, which is a flowchart of another subgraph matching method provided in an embodiment of the present application. In step a of the example shown in Figure 3a, the subgraph matching system 10 receives a query graph input by a user. The query graph can be an undirected graph, a directed graph, a non-attributed graph, or an attributed graph, without specific limitation.
[0076] Please refer to Figure 3b, which is a diagram of the graph structure of a query graph provided in an embodiment of the present application. In the example shown in Figure 3b, Figure (a) is an example of an undirected graph, in which there is no connection direction between nodes A, B, and C, and Figure (b) is an example of a directed graph, in which there is a connection direction between nodes A, B, and C, for example, node A points to node B and node C respectively.
[0077] In the example shown in Figure 3b, Figure (c) is an example of an attributed graph. In this attributed graph, nodes A, B, and C each have different attributes. The different shapes of nodes A, B, and C in the figure represent different node attributes. Figure (d) is an example of an attributeless graph. In this attributeless graph, nodes A, B, and C do not carry attribute information.
[0078] The subgraph matching system 10 can obtain a data graph through a graph data storage system. The data graph is typically stored in a graph database or other form of graph data storage system. The graph data storage system contains a large amount of graph structure data. The subgraph matching system 10 can initiate a query request to the database through an application programming interface (API) to obtain the data graph required for subgraph matching.
[0079] 202. The subgraph matching system determines the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph. The node matching order is used to indicate the order of nodes for subgraph matching in the query graph. The graph structure of the data graph is used to calculate the selectivity of the nodes in the query graph, and the selectivity is used to determine the starting node of the node matching order.
[0080] After the subgraph matching system 10 obtains the query graph and the data graph, the subgraph matching system 10 determines the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph. The node matching order is used to indicate the order of nodes in the query graph for subgraph matching, and the graph structure of the data graph is used to calculate the selectivity of the nodes in the query graph.
[0081] Specifically, the subgraph matching system 10 calculates the selectivity of each node in the query graph. The selectivity of a node refers to the number of nodes in the data graph that contain its connection relationship. Based on the selectivity, the subgraph matching system 10 determines a matching starting node, which is the node with the lowest selectivity in the query graph. Based on the number of edges connecting the remaining nodes in the query graph, the subgraph matching system 10 determines a matching node after the matching starting node, which is the node with the largest number of edges among the remaining nodes in the query graph.
[0082] Please refer to Figure 4, which is a schematic diagram of a method for calculating the selectivity of a query graph provided by an embodiment of the present application. In the example shown in Figure 4, the subgraph matching system calculates the selectivity of each node in the query graph and determines the matching starting node based on the selectivity of the node. For example, the subgraph matching system calculates the selectivity of node A, node B, node C, and node D in the query graph, respectively. The connection relationship of node A in the query graph is "1 incoming edge and 2 outgoing edges", and the only node that contains the connection relationship of node A in the data graph is node 1. Therefore, the selectivity of node A in the data graph is 1. The connection relationship of node B in the query graph is "1 incoming edge and 1 outgoing edge", and the connection relationship of node B in the data graph is node 1, node 2, node 3, and node 4. Therefore, the selectivity of node B in the data graph is 4.
[0083] Similarly, in the example shown in FIG4 , the data graph includes nodes 1, 2, 3, and 4 that have a connection relationship with node C, and the data graph includes node 4 that has a connection relationship with node D. Therefore, the subgraph matching system 10 calculates that the selectivity of node C in the query graph in the data graph is 4, and the selectivity of node D in the data graph is 1.
[0084] In the example shown in Figure 4, after calculating the selectivities of nodes A, B, C, and D in the query graph, subgraph matching system 10 determines a matching starting node based on the selectivities. Specifically, subgraph matching system 10 selects the node with the lowest selectivity as the matching starting node. For example, subgraph matching system 10 selects node A or node D, whose selectivity is 1, as the matching starting node.
[0085] In the example shown in Figure 4, after the subgraph matching system 10 determines that the starting matching node is node A, it determines the matching nodes after node A based on the number of connection edges of the remaining nodes in the query graph. The remaining nodes in the data graph are node B, node C and node D, where the number of connection edges of node B is 2, the number of connection edges of node C is 2, and the number of connection edges of node D is 3. The node with the largest number of connection edges among the remaining nodes is node D. Therefore, node D is the next matching node after node A.
[0086] In one possible implementation, after the subgraph matching system 10 determines the matching start node, if the number of edges connecting the remaining nodes in the query graph is the same, the subgraph matching system 10 determines a matching node after the matching start node based on the selectivity of the remaining nodes. Specifically, if the number of edges connecting the remaining nodes in the query graph is the same, the subgraph matching system 10 determines the node with the smallest selectivity among the remaining nodes as the next matching node.
[0087] Please continue to refer to Figure 4. In the example shown in Figure 4, after the subgraph matching system determines that node D is the next matching node after node A, since the number of connected edges of node B and node C in the remaining nodes is both 2, the subgraph matching system 10 determines the node after node D based on the selectivity of the remaining nodes. Since the selectivity of node B and node C in the remaining nodes is both 4, the subgraph matching system 10 can randomly select node B as the matching node after node D. Node C is the matching node after node B.
[0088] 4 , the node matching order generated by the subgraph matching system 10 is node A, node D, node B, and node C. The subgraph matching system 10 performs subgraph matching on the query graph according to the node matching order.
[0089] In one possible implementation, before determining the node matching order of the query graph, the subgraph matching system 10 determines the equivalence constraint relationship of the query graph based on the query graph. The equivalence constraint relationship is used to limit the matching range for subgraph matching in the data graph, and the subgraphs within the matching range satisfy the equivalence constraint relationship. The subgraph matching system 10 performs subgraph matching within the matching range in the data graph based on the node matching order. Specifically, the subgraph matching system 10 identifies equivalent points in the query graph. After the subgraph matching system exchanges the mappings of two nodes, if the graph structure of the query graph has not changed, the two nodes are equivalent nodes. The subgraph matching system sets constraint rules for the equivalent points in the query graph to obtain an equivalence constraint relationship.
[0090] In one possible implementation, when determining the equivalence constraint relationship of the query graph, the subgraph matching system 10 determines the equivalence constraint relationship based on the node identifiers of the query graph. The equivalence constraint relationship includes ascending or descending arrangement of the node identifiers of the nodes in the query graph.
[0091] Please continue to refer to Figure 3a. In steps b to c of the example shown in Figure 3a, the subgraph matching system 10 identifies equivalent points on the query graph and determines the equivalent constraint relationship of the query graph based on the equivalent points. The subgraph matching system 10 further calculates the selectivity of all nodes in the query and uses the node with the smallest selectivity as the starting matching node. The subgraph matching system 10 determines the matching nodes after the starting matching node based on the node association of the starting matching node in the query graph, thereby generating a mining plan for the query graph.
[0092] Please refer to Figure 5, which is a schematic diagram of an equivalence constraint relationship for determining a query graph provided by an embodiment of the present application. In Figure (a) of the example shown in Figure 5, the data graph G is an attributeless graph. For the query graph P1, the equivalent nodes in the query graph P1 are node A, node B, and node C. The subgraph matching system 10 sets an equivalence constraint relationship based on the node number. For example, the equivalence constraint relationship set is that the numbers of nodes A and node B are arranged in descending order, and the numbers of nodes A and node C are arranged in descending order. Under this equivalence constraint relationship, the number of subgraphs in the data graph G that match the query graph P1 is 1. If this equivalence constraint relationship does not exist, the number of subgraphs in the data graph G that match the query graph P1 is 3.
[0093] In Figure (a) of the example shown in Figure 5, for the query graph P2, the equivalent nodes in the query graph P2 are node B and node C. The subgraph matching system 10 sets an equivalence constraint based on the node number. The equivalence constraint relationship is, for example, that the numbers of node B and node C are arranged in descending order. Under this equivalence constraint relationship, the number of subgraphs in the data graph G that match the query graph P2 is 3.
[0094] For another example, for query graph P3, nodes A, B, and C in query graph P3 form an equivalence ring. The subgraph matching system 10 sets an equivalence constraint based on the node number. For example, the equivalence constraint relationship is that the numbers of nodes A and B are arranged in descending order, and the numbers of nodes A and C are arranged in descending order. Under this equivalence constraint relationship, the number of subgraphs in the data graph G that match the query graph P3 is 2.
[0095] For another example, for the query graph P4, there is no equivalent node in the query graph P4, and the subgraph matching system 10 does not set an equivalent constraint relationship. Therefore, the number of subgraphs in the data graph G that match the query graph P4 is 6.
[0096] Continuing with FIG5 , in the example diagram (b) of FIG5 , data graph G is an attribute graph. For query graph P1, since nodes A and B have different attributes, the equivalent nodes in query graph P1 are nodes B and C. The subgraph matching system 10 sets an equivalence constraint based on the node numbers. For example, the equivalence constraint sets the numbers of nodes B and C in descending order. Under this equivalence constraint, the number of subgraphs in data graph G that match query graph P1 is one.
[0097] In Figure (b) of the example shown in Figure 5, for the query graph P2, the equivalent nodes in the query graph P2 are node B and node C. The subgraph matching system 10 sets an equivalence constraint based on the node number. The equivalence constraint relationship is, for example, that the numbers of node B and node C are arranged in descending order. Under this equivalence constraint relationship, the number of subgraphs in the data graph G that match the query graph P2 is 1.
[0098] For another example, for query graph P3, there are no equivalent nodes in query graph P3, and the subgraph matching system 10 does not set an equivalence constraint relationship. Therefore, the number of subgraphs in data graph G that match query graph P3 is 2. For query graph P4, there are no equivalent nodes in query graph P4, and the subgraph matching system 10 does not set an equivalence constraint relationship. Therefore, the number of subgraphs in data graph G that match query graph P4 is 2.
[0099] 203. The subgraph matching system performs subgraph matching in the data graph based on the node matching order and generates matching results. The matching results include one or more subgraphs in the data graph with the same graph structure as the query graph.
[0100] After determining the node matching order of the query graph, the subgraph matching system 10 performs subgraph matching in the data graph based on the node matching order to generate a matching result. The matching result includes one or more subgraphs in the data graph having the same graph structure as the query graph.
[0101] Continuing with Figure 3a, in steps d through e of the example shown in Figure 3a, subgraph matching system 10 performs a dynamic depth-first search based on the node matching order in the mining plan. During this dynamic depth-first search, subgraph matching system 10 determines the minimum number of depth-first search steps based on the predicted memory consumption of the breadth-first search. After completing the subgraph matching, subgraph matching system 10 outputs the subgraph matching results, which include one or more subgraphs in the data graph that have the same graph structure as the query graph.
[0102] In one possible implementation, the subgraph matching system 10 searches the data graph for nodes in the query graph in a node matching order based on a parallel search strategy, wherein the parallel search strategy includes breadth first search (BFS) and depth first search (DFS).
[0103] Breadth-first search is an iterative graph search algorithm that begins at a starting node and expands outward layer by layer, first visiting all adjacent nodes of the starting node, then visiting their adjacent nodes, and so on. Breadth-first search uses a queue to store the nodes to be visited, ensuring a first-in, first-out order. Depth-first search is a recursive graph search algorithm that begins at a starting node and traverses along the edges of the graph until it reaches a node where it cannot proceed further, then backtracks to the nearest unvisited node and continues exploring. Depth-first search explores a branch as deeply as possible until it cannot go any deeper. This makes it suitable for deep traversals of graphs to find all possible paths and nodes. When depth-first search only takes one step at a time, it is equivalent to breadth-first search.
[0104] Please refer to Figure 6, which is a schematic diagram of a parallel search strategy provided in an embodiment of the present application. In the example shown in Figure 6, the subgraph matching system 10 searches the data graph for the nodes in the query graph in a node matching order based on the parallel search strategy. The node matching order of the query graph is node A, node B, and node C. The subgraph matching system 10 searches for node A, node B, and node C based on the depth-first search algorithm and the breadth-first search algorithm at the same time. The equivalence constraint relationship between node A, node B, and node C is that the number of node A is greater than the number of node B, and the number of node A is greater than the number of node C.
[0105] In the example shown in Figure 6, the subgraph matching system 10 performs both breadth-first search and depth-first search on the data graph based on the query graph. In the breadth-first search, the subgraph matching system 10 searches for node 1, node 2, and node 3 based on the node matching order. For example, during the search for node 1, node 1 pointing to node 2 does not satisfy the equivalence constraint relationship, and node 1 pointing to node 3 also does not satisfy the equivalence constraint relationship. When the subgraph matching system 10 has searched all adjacent nodes of node 1, the breadth-first search is stopped.
[0106] In the depth-first search, the subgraph matching system 10 searches for node 1, node 2, and node 3 based on the node matching order. For example, during the search for node 3, node 3 points to node 1, which satisfies the equivalence constraint relationship. The subgraph matching system 10 further performs a depth search on node 1, and node 1 points to node 2, which also satisfies the equivalence constraint relationship. Node 2 cannot be found anymore.
[0107] It is understandable that in the subgraph matching process of a large-scale data graph, the subgraph matching system 10 usually adopts multi-threaded parallel query. For example, in the example shown in FIG6 , nodes 1, 2, and 3 can be searched in parallel based on different threads.
[0108] In one possible implementation, the subgraph matching system 10 determines the number of depth-first search steps based on estimated memory consumption, and the estimated memory consumption is used to indicate the memory occupied by the search results of the breadth-first search that is performed in parallel with the depth-first search steps. Since the subgraph matching system 10 performs a parallel search, in the depth-first search, each thread performs a complete search task, and therefore, the depth-first search can save memory. In the breadth-first search, after each node is matched, all the current intermediate matching results are collected and redistributed, which can improve the degree of parallelism, but it takes up a lot of memory. Therefore, the subgraph matching system 10 also needs to control the memory consumption during the search process.
[0109] In the depth-first search and breadth-first search parallel search strategies of the embodiment of the present application, since the subgraph matching system requires the memory consumption of the intermediate results of the breadth-first search, and the memory consumption of the intermediate results of the breadth-first search corresponding to different depth-first search steps is different, the subgraph matching system 10 can determine the minimum number of search steps of the depth-first search by predicting the memory occupied by the search results of the breadth-first search in parallel with the depth-first search steps. The number of search steps of the depth-first search is the minimum number of steps for the search results of the parallel breadth-first search to not exceed the memory threshold.
[0110] In the embodiment of the present application, the subgraph matching system can dynamically determine the number of depth-first search steps based on the estimated memory consumption. Therefore, the parallel search strategy in the embodiment of the present application can also be called a dynamic depth-first search algorithm.
[0111] It can be seen from the above embodiments that the subgraph matching system in the embodiments of the present application can calculate the selectivity of each node in the query graph based on the graph structure of the query graph and the graph structure of the data graph, and determine the node matching order of the query graph based on the selectivity and the graph structure of the query graph, thereby improving the subgraph matching efficiency of the query graph.
[0112] Based on the above method embodiment, the embodiment of the present application further provides a sub-graph matching device. The sub-graph matching device provided by the embodiment of the present application is described in detail below.
[0113] Please refer to Figure 7, which is a schematic diagram of the structure of a subgraph matching device provided in an embodiment of the present application. In the example shown in Figure 7, subgraph matching device 700 is used to implement the various steps performed by the subgraph matching system in each of the above embodiments. Subgraph matching device 700 includes an acquisition unit 701, a sorting unit 702, a matching unit 703, and a constraint unit 704.
[0114] Among them, the acquisition unit 701 is used to obtain the query graph and the data graph, and the query graph is used to perform subgraph matching in the data graph. The sorting unit 702 is used to determine the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph. The node matching order is used to indicate the node order for subgraph matching in the query graph, and the graph structure of the data graph is used to calculate the selectivity of the nodes in the query graph, and the selectivity is used to determine the starting node of the node matching order. The matching unit 703 is used to perform subgraph matching in the data graph based on the node matching order and generate a matching result. The matching result includes one or more subgraphs in the data graph that have the same graph structure as the query graph.
[0115] In one possible implementation, the query graph includes one or more of the following: an undirected graph, a directed graph, an attributed graph, and an attributeless graph.
[0116] In one possible implementation, the sorting unit 702 is specifically configured to calculate the selectivity of each node in the query graph, where the selectivity is the number of nodes in the data graph that contain a connection relationship with the node. A matching starting node is determined based on the selectivity, where the matching starting node is the node with the lowest selectivity in the query graph. A matching node after the matching starting node is determined based on the number of edges connecting the remaining nodes in the query graph, where the matching node is the node with the largest number of edges connecting the remaining nodes in the query graph.
[0117] In a possible implementation, the sorting unit 702 is further configured to determine a matching node after the matching start node according to the selectivity of the remaining nodes when the number of connecting edges of the remaining nodes in the query graph is the same.
[0118] In one possible implementation, the apparatus further includes a constraint unit 704 configured to determine an equivalence constraint relationship based on the query graph. The equivalence constraint relationship is used to determine a matching range for subgraph matching within the data graph, where the subgraphs within the matching range satisfy the equivalence constraint relationship. The matching unit 703 is specifically configured to perform subgraph matching within the matching range in the data graph based on the node matching order.
[0119] In a possible implementation, the constraint unit 704 is specifically configured to determine an equivalence constraint relationship according to the node identifiers of the query graph. The equivalence constraint relationship includes ascending arrangement of node identifiers or descending arrangement of node identifiers of the nodes in the query graph.
[0120] In a possible implementation, the matching unit 703 is specifically configured to search the data graph for nodes in the query graph in a node matching order based on a parallel search strategy, where the parallel search strategy includes a breadth-first search and a depth-first search.
[0121] In a possible implementation, the matching unit 703 is further configured to determine the number of depth-first search steps based on estimated memory consumption, where the estimated memory consumption indicates the memory occupied by the search results of a breadth-first search performed in parallel with the depth-first search steps.
[0122] It should be noted that the above-mentioned acquisition unit 701 can be the graph data reading module 101 in the embodiment shown in Figure 1 above, the sorting unit 702 can be the mining plan generation module 103 in the embodiment shown in Figure 1 above, the matching unit 703 can be the dynamic search matching module 104 in the embodiment shown in Figure 1 above, and the constraint unit 704 can be the equivalent point constraint module 102 in the embodiment shown in Figure 1 above.
[0123] It should be understood that the division of units in the above device is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. Moreover, the units in the device can all be implemented in the form of software called through processing elements; or they can all be implemented in the form of hardware; or some units can be implemented in the form of software called through processing elements, and some units can be implemented in the form of hardware. For example, each unit can be a separately established processing element, or it can be integrated into a certain chip of the device. In addition, it can also be stored in the memory in the form of a program, called by a certain processing element of the device and perform the function of the unit. In addition, all or part of these units can be integrated together, or they can be implemented independently. The processing element described here can also be a processor, which can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each unit above can be implemented by the integrated logic circuit of the hardware in the processor element or in the form of software called through the processing element.
[0124] It is worth noting that, for the sake of simplicity of description, the above method embodiments are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited to the order of the actions described. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required for this application.
[0125] Other reasonable step combinations that can be thought of by those skilled in the art based on the above description also fall within the scope of protection of this application. Secondly, those skilled in the art should also be familiar with that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by this application.
[0126] Please refer to Figure 8, which is a schematic diagram of the structure of a computing device provided in an embodiment of the present application. As shown in Figure 8, computing device 800 includes: a processor 801, a memory 802, a communication interface 803, and a bus 804. Processor 801, memory 802, and communication interface 803 are coupled via a bus (not labeled in the figure). Memory 802 stores instructions. When the execution instructions in memory 802 are executed, computing device 800 performs the method performed by the subgraph matching system in the above method embodiment.
[0127] The computing device 800 may be one or more integrated circuits configured to implement the above method, such as one or more application specific integrated circuits (ASICs), one or more digital signal processors (DSPs), one or more field programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms. For example, when a unit in the device can be implemented in the form of a processing element scheduler, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call a program. For example, these units may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0128] The processor 801 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0129] Memory 802 may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).
[0130] Memory 802 stores executable program code, and processor 801 executes the executable program code to implement the functions of the aforementioned acquisition unit 701, sorting unit 702, matching unit 703, and constraint unit 704, thereby implementing the aforementioned subgraph matching method. In other words, memory 802 stores instructions for executing the aforementioned subgraph matching method.
[0131] The communication interface 803 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 800 and other devices or a communication network.
[0132] In addition to the data bus, bus 804 may also include a power bus, a control bus, and a status signal bus. The bus may be a Peripheral Component Interconnect Express (PCIe) bus, an Extended Industry Standard Architecture (EISA) bus, a unified bus (Ubus or UB), a Compute Express Link (CXL), or a Cache Coherent Interconnect for Accelerators (CCIX). Buses can be categorized as address buses, data buses, and control buses.
[0133] Please refer to FIG9 , which is a schematic diagram of a computing device cluster provided in an embodiment of the present application. As shown in FIG9 , the computing device cluster 900 includes at least one computing device 800 .
[0134] As shown in Figure 9, the computing device cluster 900 includes at least one computing device 800. The memory 802 in one or more computing devices 800 in the computing device cluster 900 may store the same instructions for executing the above subgraph matching method.
[0135] In some possible implementations, the memory 802 of one or more computing devices 800 in the computing device cluster 900 may also store partial instructions for executing the above-described subgraph matching method. In other words, the combination of one or more computing devices 800 may jointly execute instructions for executing the above-described subgraph matching method.
[0136] It should be noted that the memory 802 in different computing devices 800 in the computing device cluster 900 can store different instructions, each for executing a portion of the functions of the above-described subgraph matching apparatus. In other words, the instructions stored in the memory 802 in different computing devices 800 can implement the functions of one or more modules in the acquisition unit 701, the sorting unit 702, the matching unit 703, and the constraint unit 704.
[0137] In some possible implementations, one or more computing devices 800 in the computing device cluster 900 may be connected via a network, which may be a wide area network or a local area network.
[0138] In another embodiment of the present application, a computer-readable storage medium is provided, in which computer-executable instructions are stored. When the processor of the device executes the computer-executable instructions, the device executes the method executed by the sub-graph matching system in the above method embodiment.
[0139] In another embodiment of the present application, a computer program product is provided, comprising computer-executable instructions stored in a computer-readable storage medium. When a processor of a device executes the computer-executable instructions, the device performs the method performed by the subgraph matching system in the above method embodiment.
[0140] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0141] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0142] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0143] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0144] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or 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 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 method described in each embodiment of the present application. 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.
Claims
1. A subgraph matching method, characterized in that: include: Obtaining a query graph and a data graph, wherein the query graph is used to perform subgraph matching in the data graph; Determining a node matching order of the query graph based on a graph structure of the query graph and a graph structure of the data graph, wherein the node matching order indicates an order of nodes in the query graph for subgraph matching, and the graph structure of the data graph is used to calculate the selectivity of nodes in the query graph, and the selectivity is used to determine a starting node of the node matching order; Subgraph matching is performed in the data graph based on the node matching order to generate a matching result, wherein the matching result includes one or more subgraphs in the data graph having the same graph structure as the query graph.
2. The method according to claim 1, characterized in that The query graph includes one or more of the following: an undirected graph, a directed graph, an attribute graph, and an attributeless graph.
3. The method according to claim 1 or 2, characterized in that: The determining the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph comprises: Calculate the selectivity of each node in the query graph, where the selectivity is the number of nodes in the data graph that contain a connection relationship with the node; Determine a matching start node according to the selectivity, wherein the matching start node is a node with the smallest selectivity in the query graph; The matching node after the matching start node is determined according to the number of connection edges of the remaining nodes in the query graph, and the matching node is the node with the largest number of connection edges among the remaining nodes in the query graph.
4. The method according to claim 3, characterized in that The method further comprises: When the number of connection edges of the remaining nodes in the query graph is the same, the matching node after the matching start node is determined according to the selectivity of the remaining nodes.
5. The method according to any one of claims 1 to 4, characterized in that Before determining the node matching order of the query graph based on the graph structure of the query graph and the graph structure of the data graph, the method further includes: Determine an equivalence constraint relationship based on the query graph, wherein the equivalence constraint relationship is used to determine a matching range for subgraph matching in the data graph, and the subgraphs within the matching range satisfy the equivalence constraint relationship; The performing subgraph matching in the data graph based on the node matching order includes: Subgraph matching is performed within a matching range in the data graph based on the node matching order.
6. The method according to claim 5, characterized in that Determining the equivalent constraint relationship based on the query graph includes: An equivalence constraint relationship is determined according to the node identifiers of the query graph, wherein the equivalence constraint relationship includes an ascending arrangement of the node identifiers of the nodes in the query graph or a descending arrangement of the node identifiers.
7. The method according to any one of claims 1 to 5, characterized in that The performing subgraph matching in the data graph based on the node matching order includes: The data graph is searched for nodes in the query graph in a node matching order based on a parallel search strategy, wherein the parallel search strategy includes a breadth-first search and a depth-first search.
8. The method according to claim 7, characterized in that The method further comprises: The number of steps of the depth-first search is determined according to the estimated memory consumption, where the estimated memory consumption is used to indicate the memory occupied by the search results of the breadth-first search in parallel with the steps of the depth-first search.
9. A sub-graph matching device, characterized in that: include: An acquisition unit, used to acquire a query graph and a data graph, wherein the query graph is used to perform subgraph matching in the data graph; A sorting unit, configured to determine a node matching order of the query graph based on a graph structure of the query graph and a graph structure of the data graph, wherein the node matching order indicates an order of nodes in the query graph for performing subgraph matching, and the graph structure of the data graph is used to calculate a selectivity of a node in the query graph, and the selectivity is used to determine a starting node of the node matching order; A matching unit is used to perform subgraph matching in the data graph based on the node matching order to generate a matching result, wherein the matching result includes one or more subgraphs in the data graph having the same graph structure as the query graph.
10. The device according to claim 9, characterized in that The query graph includes one or more of the following: an undirected graph, a directed graph, an attribute graph, and an attributeless graph.
11. The device according to claim 9 or 10, characterized in that The sorting unit is specifically used for: Calculate the selectivity of each node in the query graph, where the selectivity is the number of nodes in the data graph that contain a connection relationship with the node; Determine a matching start node according to the selectivity, wherein the matching start node is a node with the smallest selectivity in the query graph; The matching node after the matching start node is determined according to the number of connection edges of the remaining nodes in the query graph, and the matching node is the node with the largest number of connection edges among the remaining nodes in the query graph.
12. The device according to claim 11, characterized in that The sorting unit is also used for: When the number of connection edges of the remaining nodes in the query graph is the same, the matching node after the matching start node is determined according to the selectivity of the remaining nodes.
13. The device according to any one of claims 9 to 12, characterized in that The device further comprises a constraint unit, which is used to: Determine an equivalence constraint relationship based on the query graph, wherein the equivalence constraint relationship is used to determine a matching range for subgraph matching in the data graph, and the subgraphs within the matching range satisfy the equivalence constraint relationship; The matching unit is specifically used for: Subgraph matching is performed within a matching range in the data graph based on the node matching order.
14. The device according to claim 12, characterized in that The constraint unit is specifically used for: An equivalence constraint relationship is determined according to the node identifiers of the query graph, wherein the equivalence constraint relationship includes an ascending arrangement of the node identifiers of the nodes in the query graph or a descending arrangement of the node identifiers.
15. The device according to any one of claims 9 to 14, characterized in that The matching unit is specifically used for: The data graph is searched for nodes in the query graph in a node matching order based on a parallel search strategy, wherein the parallel search strategy includes a breadth-first search and a depth-first search.
16. The device according to claim 15, characterized in that The matching unit is also used for: The number of steps of the depth-first search is determined according to the estimated memory consumption, where the estimated memory consumption is used to indicate the memory occupied by the search results of the breadth-first search in parallel with the steps of the depth-first search.
17. A computing device, characterized in that The electronic device comprises a processor coupled to a memory, wherein the processor is used to store instructions. When the instructions are executed by the processor, the electronic device executes the method according to any one of claims 1 to 8.
18. A computing device cluster, characterized in that: The system comprises at least one computing device, wherein the computing device comprises a processor, wherein the processor is coupled to a memory, and the processor is used to store instructions. When the instructions are executed by the processor, the computing device cluster executes the method according to any one of claims 1 to 8.
19. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed, the computer is caused to perform the method according to any one of claims 1 to 8.
20. A computer program product, comprising instructions, characterized in that: When the instructions are executed, the computer implements the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Tree search-based RDF query method
CN110990426A
Graph pattern matching method based on multi-source-point parallel exploration
CN112559807A
Ontology label knowledge graph-oriented sample query method
CN113569057A
Sub-graph matching method and system based on heterogeneous computer FPGA
CN114661757A
Data acquisition method and device for fault diagnosis of oil purifier
KR102656658B1
Cited By
Enhanced VF3 algorithm-based netlist subgraph matching method, storage medium and equipment
CN121525610A