Directed acyclic graph reachability query method and system based on structured jump index

By adopting structured jump indexing in directed acyclic graphs, the query efficiency problem of the prior art on large-scale and complex graph data is solved, and efficient query on dense graphs and effective compression of index space is achieved.

CN119646263AInactive Publication Date: 2025-03-18SHANGHAI JIAOTONG UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411618293.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-13
Publication Date
2025-03-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The prior art is difficult to achieve an ideal balance between index space and query time when processing large-scale and complex graph data, especially poor performance on dense graphs.

Method used

The directed acyclic graph accessibility query method based on structured jump index is adopted, and the index is constructed through topological sorting and depth-first search, and the index structure is optimized to improve query speed.

Benefits of technology

It significantly improves query speed on large-scale graphs, especially on dense graphs, reduces index space and storage overhead, and achieves a good balance between index space and query time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119646263A_ABST
    Figure CN119646263A_ABST
Patent Text Reader

Abstract

The invention provides a directed acyclic graph reachability query method and system based on a structured jump index, and the method comprises the steps: S1, carrying out the topological sorting of a directed acyclic graph G, and carrying out the calculation to obtain a depth-first search starting point; s2, starting depth-first search from all starting points in sequence, and constructing a depth-first search serial number and an index in the depth-first search process; and S3, based on the index and the depth-first search serial number, judging the accessibility between the queried source node and the queried target node. According to the directed acyclic graph reachability query method based on the structured jump index, reachability information of the directed acyclic graph can be stored through a small index, a reachability query result can be returned in a short time, and the size of an index space and query time can be conveniently adjusted and balanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of network big data analysis, and in particular to a directed acyclic graph reachability query method and system based on structured jump index. Background Art

[0002] As a fundamental and crucial problem in the field of graph data structures, graph reachability query is widely used in many fields such as databases and network analysis. In actual application scenarios, how to quickly determine whether there is a path between any two vertices in the graph is of great significance to improving the response speed of the system.

[0003] However, with the rapid development of information technology, the scale of graphs continues to grow and their structures become increasingly complex. Traditional graph reachability query methods can no longer meet the current urgent need for efficient queries when facing such large and complex graph data. Therefore, designing efficient graph reachability algorithms has become an important research direction. As for the existing algorithms, they all have limitations in different programs. For example, although the Path Tree and GRAIL algorithms are based on certain theoretical foundations, they are slow in actually executing query operations and it is difficult to achieve fast queries in the face of large-scale graph data; although the BFL algorithm has improved query speed compared to the previous two, when its index space continues to increase, it cannot guarantee that the query time will decrease monotonically, which leads to uncertainty in optimizing query efficiency.

[0004] In addition, many algorithms focus on optimizing sparse graphs with a small average degree, which leads to a significant drop in performance when processing dense graphs. Especially in the context of large-scale dense graphs, it is even more difficult for existing methods to find an ideal balance between index space and query time.

[0005] Through searching patent documents, it is found that the invention patent with publication number CN116108238B discloses a method, system and device for optimizing multi-hop queries in a graph database, wherein the method includes: initializing the query attributes of all nodes in the graph data of the graph database; setting the query attributes of the specified node so that the specified node is activated as an active node; repeatedly performing the query attribute selection and calculation of the query attributes of the direct neighbor nodes based on the query attributes of the active node, and when the number of iterative calculations reaches the preset number, the query attributes of the nodes participating in the iterative calculation are counted to obtain the multi-hop query results of the specified node. This patent does not optimize the index structure for different types of graph data to improve the query speed, especially the performance is poor on dense graphs.

[0006] In summary, in response to the above-mentioned problems of the existing technology, studying an algorithm that can adapt to dense graphs and achieve an ideal balance between index space and query time has become an important issue in current graph reachability research. Summary of the invention

[0007] In view of the defects in the prior art, the object of the present invention is to provide a directed acyclic graph reachability query method and system based on structured jump index.

[0008] A directed acyclic graph reachability query method based on structured jump index provided by the present invention comprises the following steps:

[0009] Step S1, topologically sorting the directed acyclic graph G, and calculating the starting point of the depth-first search;

[0010] Step S2, starting a depth-first search from all starting points in turn, and during the depth-first search process, constructing a depth-first search sequence number and index;

[0011] Step S3, based on the index and the depth-first search sequence number, determine the reachability between the queried source node and the target node.

[0012] Preferably, step S1 includes the following sub-steps:

[0013] Step S1.1, topologically sorting the directed acyclic graph G so that the successor nodes of each node in the graph are arranged in topological order;

[0014] Step S1.2, initializing the variable num representing the access time to 0;

[0015] Step S1.3, enumerate each node in the directed acyclic graph G in turn, and calculate the indegree of each node. If the indegree value indegree(u) of node u is 0, then node u is one of the starting points of the depth-first search.

[0016] Preferably, step S2 includes the following sub-steps:

[0017] Step 2.1, recursively perform a depth-first search on the successor nodes of the current node, and record the depth-first search sequence number pairs;

[0018] Step 2.2, constructing a shallow hop index based on the shallow hop and deep hop information of the direct successor node of each node and combining with a preset parameter k;

[0019] Step 2.3, construct a deep hop index based on the shallow hop and deep hop information of the direct successor node of each node and the parameter k;

[0020] Step 2.4, if the sum of the shallow hop and deep hop sizes of the current node is not less than k, then build a pseudo hop index with the help of the pseudo hop information of the deep hop and deep hop nodes; if the sum of the shallow hop and deep hop sizes of the current node is less than k, then directly enter step S3.

[0021] Preferably, step 2.1 includes the following sub-steps:

[0022] Step 2.1.1, mark the current point u as visited;

[0023] Step 2.1.2, increment the variable num, i.e. num=num+1;

[0024] Step 2.1.3, assign the value of num to ul;

[0025] Step 2.1.4, enumerate each successor node v of node u. If v has not been visited, recursively start depth-first search from v.

[0026] Step 2.1.5, after the recursive depth-first search is completed, assign the updated num value to ur.

[0027] Preferably, step 2.2 includes the following sub-steps:

[0028] Step 2.2.1, create an empty shallow hop ordered node set;

[0029] Step 2.2.2, enumerate each successor node v of node u. If the sum of the shallow hops and deep hops of node v is less than k, then add v to the shallow hop ordered node set, and merge the shallow hops of v into the shallow hop ordered node set;

[0030] Step 2.2.3, delete the nodes in the shallow jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the shallow jump ordered node set to u's shallow jump index uJ s .

[0031] Preferably, step 2.3 includes the following sub-steps:

[0032] Step 2.3.1, create an empty deep jump ordered node set;

[0033] Step 2.3.2, enumerate each successor node v of node u; if the sum of the shallow jump and deep jump of node v is less than k, then vJ d Merge into the deep jump ordered node set; otherwise, add v to the deep jump ordered node set;

[0034] Step 2.3.3, delete the nodes in the deep jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the deep jump ordered node set to the deep jump index uJ of u d .

[0035] Preferably, in step 2.4, constructing the pseudo jump index includes the following sub-steps:

[0036] Step 2.4.1: Create an empty pseudo-hop ordered node set;

[0037] Step 2.4.2: Add node u to the pseudo-hop ordered node set; and set the shallow hop index uJ of node u s Merge into the pseudo-hop ordered node set;

[0038] Step 2.4.3: Enumerate the deep hop index uJ of node u d For each node v in; the pseudo-hop index vJ of node v f Merge into the pseudo-hop ordered node set;

[0039] Step 2.4.4: Delete the nodes in the pseudo-hop ordered node set that are covered by the left and right sequence number intervals of other nodes;

[0040] Step 2.4.5: If the size of the pseudo-hop ordered node set exceeds the preset parameter f, sort the differences of all adjacent node intervals in the pseudo-hop ordered node set from small to large, and merge the adjacent nodes into a new node in sequence until the size of the pseudo-hop ordered node set is equal to f;

[0041] Step 2.4.6: Assign the pseudo-hop ordered node set to the pseudo-hop index uJ f .

[0042] Preferably, step S3 includes the following sub-steps:

[0043] Step S3.1, obtain the source node source and the target node target of the query;

[0044] Step S3.2, if target.l>source.r, then return false, indicating that the source node source is unreachable to the target node target; otherwise, if target.l≥source.l, then return true, indicating that the source node source is reachable to the target node target;

[0045] Step S3.3, if the source node source has a pseudo jump source.J f , and source.J f If target.l is not included, false is returned, indicating that it is unreachable;

[0046] Step S3.4, mark source as visited, initialize an empty stack, and then push source into the empty stack;

[0047] Step S3.5, loop to determine whether the stack is empty; if the stack is empty, exit the loop and return false, indicating that the source node source is unreachable to the target node target; if the stack is not empty, repeat the reachability loop steps until the loop end condition is met.

[0048] Preferably, the reachability loop step comprises:

[0049] Step S3.5.1, pop the top element of the stack, denoted as cur, if cur.J s If target.l is included, true is returned, indicating that the source node source is reachable to the target node target;

[0050] Step S3.5.2, if cur.J s If target.l is not included, cur.J is enumerated in reverse order. d Every element j of

[0051] Step S3.5.2 includes:

[0052] If target.l≥jl; further, if target.l≤jr, then return true, indicating that the source node source is reachable to the target node target; otherwise, return to step 3.5;

[0053] If j has not been visited, then j is marked as visited; further, if jJ f If target.l is included, j is pushed into the stack and cur.J is enumerated. d The next element j in .

[0054] The present invention also provides a directed acyclic graph reachability query system based on structured jump index, comprising:

[0055] Module M1, topologically sorts the directed acyclic graph G and calculates the starting point of the depth-first search;

[0056] Module M2 starts depth-first search from all starting points in turn, and during the depth-first search process, builds a depth-first search sequence number and index;

[0057] Module M3 determines the reachability between the source node and the target node of the query based on the index and the depth-first search sequence number.

[0058] Compared with the prior art, the present invention has the following beneficial effects:

[0059] 1. A directed acyclic graph reachability query method based on structured jump index improves the query speed on large-scale graphs by optimizing the index structure, especially showing better performance on dense graphs, overcoming the query bottleneck of existing algorithms on such graphs;

[0060] 2. Compared with existing algorithms, the present invention can effectively compress index space and reduce storage overhead, especially when processing large-scale graphs, significantly reducing the occupation of system resources;

[0061] 3. The present invention achieves a better balance between index space and query time, avoiding the limitation of existing algorithms that the increase in index space may not lead to a significant reduction in query time;

[0062] 4. The present invention can process sparse graphs and can efficiently process dense graphs, which expands the scope of application of the algorithm and overcomes the shortcomings of existing algorithms that have reduced performance on dense graphs. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

[0064] Figure 1 A flow chart of a directed acyclic graph reachability query method based on a structured jump index in an embodiment of the present invention;

[0065] Figure 2 A simple example directed acyclic graph in an embodiment of the present invention;

[0066] Figure 3 For Figure 2 Schematic diagram of the jump index constructed on. DETAILED DESCRIPTION

[0067] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0068] The present invention provides a directed acyclic graph reachability query method based on a structured jump index, so that the reachability information of the directed acyclic graph can be stored through a smaller index, and the reachability query result can be returned in a shorter time, and the size of the index space and the query time can be conveniently adjusted and balanced.

[0069] Related definitions:

[0070] Definition 1: G is a directed acyclic graph.

[0071] Definition 4: ul is the left index of the u node, indicating the time sequence number when the depth-first search for u begins.

[0072] Definition 4: ur is the right index of the u node, indicating the time sequence number when the depth-first search for u ends.

[0073] Definition 4: uJ s , is a shallow hop of node u, representing an ordered set of nodes reachable by u that can be directly determined.

[0074] Definition 5: uJ d , is the deep hop of node u, indicating the ordered set of nodes reachable by u that need further judgment.

[0075] Definition 6: uJ f , is the pseudo-hop of node u, representing the ordered set of all node intervals that u may reach.

[0076] Definition 7: k is a spatial parameter that controls whether a node is placed in a deep jump; if the sum of the shallow jump and deep jump sizes of a node exceeds k, a deep jump should be placed.

[0077] Definition 8: f is the spatial parameter that controls the pseudo-hop size. The pseudo-hop length of a node cannot exceed f.

[0078] Definition 9: indegree(u) is the indegree of node u.

[0079] Embodiment 1:

[0080] Figure 1 The present invention is a flowchart of a directed acyclic graph reachability query method based on a structured jump index in an embodiment of the present invention.

[0081] like Figure 1 As shown, this embodiment provides a directed acyclic graph reachability query method based on a structured jump index, comprising the following steps:

[0082] Step S1, topologically sort the directed acyclic graph G, and calculate the starting point of the depth-first search.

[0083] Specifically, step S1 includes the following sub-steps:

[0084] Step S1.1, topologically sorting the directed acyclic graph G so that the successor nodes of each node in the graph are arranged in topological order;

[0085] Step S1.2, initializing the variable num representing the access time to 0;

[0086] Step S1.3, enumerate each node in the directed acyclic graph G in turn, and calculate the indegree of each node. If the indegree value indegree(u) of node u is 0, then node u is one of the starting points of the depth-first search.

[0087] Step S2, starting a depth-first search from all starting points in sequence, and during the depth-first search process, constructing a depth-first search sequence number and index.

[0088] Specifically, step S2 includes the following sub-steps:

[0089] Step 2.1, recursively perform a depth-first search on the successor nodes of the current node, and record the depth-first search sequence number pairs.

[0090] More specifically, step 2.1 includes the following sub-steps:

[0091] Step 2.1.1, mark the current point u as visited;

[0092] Step 2.1.2, increment the variable num, i.e. num=num+1;

[0093] Step 2.1.3, assign the value of num to ul;

[0094] Step 2.1.4, enumerate each successor node v of node u. If v has not been visited, recursively start depth-first search from v.

[0095] Step 2.1.5, after the recursive depth-first search is completed, assign the updated num value to ur.

[0096] Step 2.2, construct a shallow hop index based on the shallow hop and deep hop information of the direct successor node of each node and combined with the preset parameter k.

[0097] More specifically, step 2.2 includes the following sub-steps:

[0098] Step 2.2.1, create an empty shallow hop ordered node set;

[0099] Step 2.2.2, enumerate each successor node v of node u. If the sum of the shallow hops and deep hops of node v is less than k, then add v to the shallow hop ordered node set, and merge the shallow hops of v into the shallow hop ordered node set;

[0100] Step 2.2.3, delete the nodes in the shallow jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the shallow jump ordered node set to u's shallow jump index uJ s .

[0101] Step 2.3, construct a deep hop index based on the shallow hop and deep hop information of each node's direct successor node and the parameter k.

[0102] More specifically, step 2.3 includes the following sub-steps:

[0103] Step 2.3.1, create an empty deep jump ordered node set;

[0104] Step 2.3.2, enumerate each successor node v of node u; if the sum of the shallow jump and deep jump of node v is less than k, then vJ d Merge into the deep jump ordered node set; otherwise, add v to the deep jump ordered node set;

[0105] Step 2.3.3, delete the nodes in the deep jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the deep jump ordered node set to the deep jump index uJ of u d .

[0106] Step 2.4, if the sum of the shallow hop and deep hop sizes of the current node is not less than k, then build a pseudo hop index with the help of the pseudo hop information of the deep hop and deep hop nodes; if the sum of the shallow hop and deep hop sizes of the current node is less than k, then directly enter step S3.

[0107] More specifically, constructing the pseudo jump index includes the following sub-steps:

[0108] Step 2.4.1: Create an empty pseudo-hop ordered node set;

[0109] Step 2.4.2: Add node u to the pseudo-hop ordered node set; and set the shallow hop index uJ of node u s Merge into the pseudo-hop ordered node set;

[0110] Step 2.4.3: Enumerate the deep hop index uJ of node u d For each node v in; the pseudo-hop index vJ of node v f Merge into the pseudo-hop ordered node set;

[0111] Step 2.4.4: Delete the nodes in the pseudo-hop ordered node set that are covered by the left and right sequence number intervals of other nodes;

[0112] Step 2.4.5: If the size of the pseudo-hop ordered node set exceeds the preset parameter f, sort the differences of all adjacent node intervals in the pseudo-hop ordered node set from small to large, and merge the adjacent nodes into a new node in sequence until the size of the pseudo-hop ordered node set is equal to f;

[0113] Step 2.4.6: Assign the pseudo-hop ordered node set to the pseudo-hop index uJ f .

[0114] Step S3, based on the index and the depth-first search sequence number, determine the reachability between the queried source node and the target node.

[0115] Specifically, step S3 includes the following sub-steps:

[0116] Step S3.1, obtain the source node source and the target node target of the query;

[0117] Step S3.2, if target.l>source.r, then return false, indicating that the source node source is unreachable to the target node target; otherwise, if target.l≥source.l, then return true, indicating that the source node source is reachable to the target node target.

[0118] Step S3.3, if the source node source has a pseudo jump source.J f , and source.J f If target.l is not included, false is returned, indicating that it is unreachable;

[0119] Step S3.4, mark source as visited, initialize an empty stack, and then push source into the empty stack;

[0120] Step S3.5, loop to determine whether the stack is empty; if the stack is empty, exit the loop and return false, indicating that the source node source is unreachable to the target node target; if the stack is not empty, repeat the reachability loop steps until the loop end condition is met.

[0121] Specifically, the reachability cycle steps include:

[0122] Step S3.5.1, pop the top element of the stack, denoted as cur, if cur.J s If target.l is included, true is returned, indicating that the source node source is reachable to the target node target;

[0123] Step S3.5.2, if cur.J s If target.l is not included, cur.J is enumerated in reverse order. d Every element j of .

[0124] Specifically, step S3.5.2 includes:

[0125] If target.l≥jl; further, if target.l≤jr, then return true, indicating that the source node source is reachable to the target node target; otherwise, return to step 3.5;

[0126] If j has not been visited, then j is marked as visited; further, if jJ f If target.l is included, j is pushed into the stack and cur.J is enumerated. d The next element j in .

[0127] Embodiment 2:

[0128] Figure 2 A simple example directed acyclic graph in an embodiment of the present invention.

[0129] like Figure 2 As shown, there are 10 user vertices in the directed acyclic graph G, represented by V = {a, b, ..., j}. Define k = 1, f = 1.

[0130] Perform topological sorting on all the points in the directed acyclic graph G, and the resulting order is a, b, c, d, e, f, g, h, i, j. Take the points with in-degree 0, i.e. a and g, as the starting points. Start the depth-first search from a and g, and the order of the depth-first search of each node is a, b, c, d, e, f, g, h, i, j. Construct the index according to step S2.

[0131] Figure 3 For Figure 2 Schematic diagram of the jump index constructed on.

[0132] The constructed index is shown in Figure 3 and Table 1.

[0133] Table 1 Node index information

[0134]

[0135] In the index, k, l, and m are pseudo nodes constructed to store the merged pseudo hop information.

[0136] Next, we give an example of querying whether three nodes are reachable:

[0137] Node h to node f: First determine the relationship between the left and right numbers of h and f, and the result cannot be returned directly. s is empty, so from hJ d Start; due to hJ d The pseudo jump of i in iJ contains the interval of f, so we can continue to analyze i. s Excluding f, continue from iJ d The judgment is based on j. s Contains f, so returns true, indicating that it is reachable.

[0138] Node f to node h: Since hl=8, which is greater than fr=6, the corresponding depth-first search order indicates that f to h is unreachable, and returns false.

[0139] Node c to node b: First determine the relationship between the left and right serial numbers of c and b. The result cannot be obtained directly. fThe interval does not include b, so false can be returned directly, indicating that it is unreachable.

[0140] Embodiment 3:

[0141] The present embodiment provides a directed acyclic graph reachability query system based on a structured jump index. The directed acyclic graph reachability query system based on a structured jump index can be implemented by executing the process steps of a directed acyclic graph reachability query method based on a structured jump index, that is, those skilled in the art can understand the directed acyclic graph reachability query method based on a structured jump index as a preferred implementation of the directed acyclic graph reachability query system based on a structured jump index.

[0142] The directed acyclic graph reachability query system includes:

[0143] Module M1 performs topological sorting on the directed acyclic graph G and calculates the starting point of the depth-first search.

[0144] Module M2 starts depth-first search from all starting points in turn, and during the depth-first search process, builds a depth-first search sequence number and index.

[0145] Module M3 determines the reachability between the source node and the target node of the query based on the index and the depth-first search sequence number.

[0146] The present invention improves the query speed on large-scale graphs by optimizing the index structure, especially showing better performance on dense graphs, overcoming the query bottleneck of existing algorithms on such graphs. Secondly, the present invention can effectively compress the index space and reduce storage overhead, especially when processing large-scale graphs, significantly reducing the occupation of system resources. Furthermore, the present invention achieves a better balance between index space and query time, effectively avoiding the limitation of existing algorithms that even if the index space is increased, the query time may not be significantly reduced. Finally, the present invention can process sparse graphs and can efficiently process dense graphs at the same time, expanding the scope of application of the algorithm and overcoming the shortcomings of existing algorithms that have reduced performance on dense graphs.

[0147] Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.

[0148] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims

1. A directed acyclic graph reachability query method based on structured jump index, characterized in that: The steps include: Step S1, topologically sorting the directed acyclic graph G, and calculating the starting point of the depth-first search; Step S2, starting a depth-first search from all starting points in turn, and during the depth-first search process, constructing a depth-first search sequence number and index; Step S3: Based on the index and the depth-first search sequence number, determine the reachability between the queried source node and the target node.

2. The directed acyclic graph reachability query method based on structured jump index according to claim 1, characterized in that: The step S1 includes the following sub-steps: Step S1.1, topologically sorting the directed acyclic graph G so that the successor nodes of each node in the graph are arranged in topological order; Step S1.2, initializing the variable num representing the access time to 0; Step S1.3, enumerate each node in the directed acyclic graph G in turn, and calculate the indegree of each node. If the indegree value indegree(u) of node u is 0, then the node u is one of the starting points of the depth-first search.

3. The directed acyclic graph reachability query method based on structured jump index according to claim 1, characterized in that: The step S2 includes the following sub-steps: Step 2.1, recursively perform a depth-first search on the successor nodes of the current node, and record the depth-first search sequence number pairs; Step 2.2, constructing a shallow hop index based on the shallow hop and deep hop information of the direct successor node of each node and combining with a preset parameter k; Step 2.3, constructing a deep hop index according to the shallow hop and deep hop information of the direct successor node of each node and combining the parameter k; Step 2.4, if the sum of the shallow hop and deep hop sizes of the current node is not less than k, then construct a pseudo-hop index with the help of the pseudo-hop information of the deep hop and deep hop nodes; If the sum of the shallow hop and deep hop sizes of the current node is less than k, go directly to step S3.

4. The directed acyclic graph reachability query method based on structured jump index according to claim 3, characterized in that: The step 2.1 includes the following sub-steps: Step 2.1.1, mark the current point u as visited; Step 2.1.2, increment the variable num, i.e. num=num+1; Step 2.1.3, assign the value of num to ul; Step 2.1.4, enumerate each successor node v of node u. If v has not been visited, recursively start depth-first search from v. Step 2.1.5, after the recursive depth-first search is completed, assign the updated num value to ur.

5. The directed acyclic graph reachability query method based on structured jump index according to claim 3, characterized in that: The step 2.2 includes the following sub-steps: Step 2.2.1, create an empty shallow hop ordered node set; Step 2.2.2, enumerate each successor node v of node u, if the sum of the shallow hops and deep hops of node v is less than k, then add v to the shallow hop ordered node set, and merge the shallow hops of v into the shallow hop ordered node set; Step 2.2.3, delete the nodes in the shallow jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the shallow jump ordered node set to the shallow jump index uJ of u s .

6. The directed acyclic graph reachability query method based on structured jump index according to claim 3, characterized in that: The step 2.3 includes the following sub-steps: Step 2.3.1, create an empty deep jump ordered node set; Step 2.3.2, enumerate each successor node v of node u; if the sum of the shallow jump and deep jump of node v is less than k, then vJ d Merge into the deep jump ordered node set; otherwise, add v to the deep jump ordered node set; Step 2.3.3, delete the nodes in the deep jump ordered node set that are covered by the left and right sequence number intervals of other nodes, and then assign the deep jump ordered node set to the deep jump index uJ of u d .

7. The directed acyclic graph reachability query method based on structured jump index according to claim 3, characterized in that: In step 2.4, constructing the pseudo jump index includes the following sub-steps: Step 2.4.1: Create an empty pseudo-hop ordered node set; Step 2.4.2: Add node u to the pseudo-hop ordered node set; and set the shallow hop index uJ of node u s Incorporating the pseudo-hop ordered node set; Step 2.4.3: Enumerate the deep hop index uJ of node u d For each node v in; the pseudo-hop index vJ of node v f Merge into the pseudo-hop ordered node set; Step 2.4.4: Delete the nodes in the pseudo-hop ordered node set that are covered by the left and right sequence number intervals of other nodes; Step 2.4.5: If the size of the pseudo-hop ordered node set exceeds a preset parameter f, the differences of all adjacent node intervals in the pseudo-hop ordered node set are sorted from small to large, and the adjacent nodes are merged into a new node in sequence until the size of the pseudo-hop ordered node set is equal to f; Step 2.4.6: Assign the pseudo-jump ordered node set to the pseudo-jump index uJ f .

8. The directed acyclic graph reachability query method based on structured jump index according to claim 1, characterized in that: The step S3 includes the following sub-steps: Step S3.1, obtain the source node source and the target node target of the query; Step S3.2, if target.l>source.r, then return false, indicating that the source node source is unreachable to the target node target; otherwise, if target.l≥source.l, then return true, indicating that the source node source is reachable to the target node target; Step S3.3, if the source node source has a pseudo jump source.J f , and source.J f If target.l is not included, false is returned, indicating that it is unreachable; Step S3.4, mark source as visited, initialize an empty stack, and then push source into the empty stack; Step S3.5, loop to determine whether the stack is empty; if the stack is empty, exit the loop and return false, indicating that the source node source is unreachable to the target node target; if the stack is not empty, repeat the reachability loop steps until the loop end condition is met.

9. The directed acyclic graph reachability query method based on structured jump index according to claim 8, characterized in that: The reachability loop steps include: Step S3.5.1, pop the top element of the stack, denoted as cur, if cur.J s If target.l is included, true is returned, indicating that the source node source is reachable to the target node target; Step S3.5.2, if cur.J s If target.l is not included, cur.J is enumerated in reverse order. d Every element j of The step S3.5.2 comprises: If target.l≥jl; further, if target.l≤jr, then return true, indicating that the source node source is reachable to the target node target; otherwise, return to step 3.5; If j has not been visited, then j is marked as visited; further, if jJ f If target.l is included, j is pushed into the stack and cur.J is enumerated. d The next element j in .

10. A directed acyclic graph reachability query system based on structured jump index, characterized in that: include: Module M1, topologically sorts the directed acyclic graph G and calculates the starting point of the depth-first search; Module M2 starts depth-first search from all starting points in turn, and during the depth-first search process, builds a depth-first search sequence number and index; Module M3 determines the reachability between the source node and the target node of the query based on the index and the depth-first search sequence number.

Citation Information

Patent Citations

  • An optimization method, system, and apparatus for multi-hop queries in graph databases.

    CN116108238B