A database graph index construction and shortest path acceleration method, device and medium
Patent Information
- Application Number
- CN202611401811.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-10
- Publication Date
- 2026-10-13
AI Technical Summary
[0006]本发明实施例提供了一种数据库图索引构建与最短路径加速方法、设备及介质,用于解决如下技术问题:现有Apache AGE图数据库缺乏内核级图拓扑加速机制,导致在大规模动态图谱场景下,最短路径查询遍历空间大、无效计算多、时延高且易超时
第一,本申请通过在内核层构建邻接表拓扑索引,以节点为索引键直接记录并检索节点对应的关联边、邻接节点与关系类型,能够将节点邻接集合的获取由全表遍历转变为索引直接读取,使拓扑关联检索的时间复杂度降低,从而降低大规模图谱场景下最短路径查询的磁盘IO开销,缩短查询时延。
Smart Images

Figure CN122903666A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database kernel optimization technology, and in particular to a method, device and medium for database graph index construction and shortest path acceleration. Background Technology
[0002] Apache AGE is a mainstream open-source graph database within the PostgreSQL database ecosystem. It enables hybrid storage of graph and relational data and is widely used in core business scenarios such as financial risk control, social networks, knowledge graphs, link tracing, and network topology analysis. Among these, shortest path queries and multi-hop association queries are the most frequent core scenarios for graph databases and are also key indicators for measuring graph data processing performance.
[0003] As business data scale rapidly increases, graph data has evolved from the traditional millions of vertices to ultra-large graphs with hundreds of millions of vertices and billions of edges. The technical shortcomings of the native Apache AGE architecture have been gradually exposed. The native Apache AGE did not design a dedicated optimization mechanism for graph topology structures, and mainly relied on the native row storage traversal logic of the PostgreSQL database to implement path queries.
[0004] First, Apache AGE lacks a kernel-level topology-specific index, resulting in huge I / O overhead for large image retrieval. Second, its unidirectional breadth-first full traversal mechanism leads to search space explosion and a very high percentage of invalid traversals. Furthermore, the use of a full traversal followed by a selection mechanism lacks early termination logic, making queries on extremely large graphs prone to timeouts. Finally, existing optimizations are all modifications to upper-level plugins, not native kernel optimizations, resulting in poor data consistency, low performance ceiling, and difficulty in supporting high-concurrency, dynamically updated scenarios.
[0005] In summary, the existing Apache AGE graph query system has inherent defects such as index mismatch, large traversal space, inability to terminate early, and poor consistency due to non-kernel optimization. These defects lead to high latency, resource waste, insufficient stability, and frequent timeouts in shortest path queries on large-scale graphs, thus hindering the large-scale deployment of PostgreSQL graph services. Summary of the Invention
[0006] This invention provides a database graph index construction and shortest path acceleration method, device and medium to solve the following technical problem: the existing Apache AGE graph database lacks a kernel-level graph topology acceleration mechanism, which results in large shortest path query traversal space, many invalid calculations, high latency and easy timeout in large-scale dynamic graph scenarios.
[0007] The embodiments of the present invention adopt the following technical solutions: On one hand, embodiments of the present invention provide a method for constructing a database graph index and accelerating the shortest path, the method including: constructing and incrementally updating the adjacency table topology index in real time when writing graph data; Receive and parse the shortest path query request from the client, and extract the query parameters; wherein, the query parameters include at least the start node and the end node; Based on the adjacency list topology index, obtain the forward adjacency set of the starting node and the reverse adjacency set of the ending node; Starting from the starting node and the ending node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set. During the traversal, multi-level dynamic pruning operations are performed on the node advancement path to obtain the forward traversal node set and the reverse traversal node set. When the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, and the shortest path query result is returned.
[0008] In one feasible implementation, the adjacency table topology index is built and incrementally updated in real time when the graph data is written, specifically including: When the graph data is written for the first time, the adjacency table topology index is constructed in real time in the kernel layer; wherein, the adjacency table topology index uses the node as the index key and records the associated edge, adjacent node, relationship type and hop weight of the node; When new data is added to the graph, the corresponding topology index entry for the node in the adjacency table topology index is added synchronously. When a deletion operation occurs in the graph data, the corresponding invalid topological index entry in the adjacency table topological index is deleted; When the attributes of nodes or edges in the graph data are updated, the relation attributes and hop count weight information in the corresponding topological index entries are updated incrementally.
[0009] In one feasible implementation, the adjacency list topology index adopts a hash table structure with node ID as the index key; the index value stores outgoing edge information, incoming edge information, adjacent node ID, relationship type, creation time and hop count weight in an orderly manner, and caches the adjacency data of hot nodes through kernel shared memory.
[0010] In one feasible implementation, based on the adjacency table topology index, the forward adjacency set of the starting node and the reverse adjacency set of the ending node are obtained, specifically including: The kernel layer's topology index fast retrieval interface is invoked to read all adjacent nodes of the starting node from the adjacency list topology index, forming the forward adjacency set; at the same time, all adjacent nodes of the ending node are read to form the reverse adjacency set.
[0011] In one feasible implementation, starting from the start node and the end node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set, specifically including: Initialize the bidirectional traversal queue and set the maximum number of jumps threshold; Starting from the starting node, the associated edges and adjacent nodes in the forward adjacency set are traversed in a breadth-first manner to obtain forward candidate paths; the nodes and associated edges contained in the forward candidate paths are stored in the bidirectional traversal queue. Simultaneously, starting from the termination node, the associated edges and adjacent nodes in the reverse adjacency set are traversed in reverse order in a breadth-first manner to obtain the reverse candidate path; the nodes and associated edges contained in the reverse candidate path are stored in the bidirectional traversal queue. The adjacency list topology index is used to perform path association analysis on the forward candidate path and the reverse candidate path to construct an initial candidate path tree.
[0012] In one feasible implementation, multi-level dynamic pruning operations are performed on the node advancement path during the traversal process to obtain a set of nodes traversed in the forward direction and a set of nodes traversed in the reverse direction, specifically including: After obtaining the initial candidate path tree, redundant paths are pruned using a multi-level dynamic pruning method to obtain the final candidate path tree. The nodes in the final candidate path tree are then divided into the forward traversal node set and the reverse traversal node set according to the different starting nodes. The multi-level dynamic pruning method includes loop pruning, length pruning, and repeat node pruning. The loop pruning includes: recording all visited nodes of a single path during traversal; when a duplicate node appears in the current path, it is determined to be a loop path and the current traversal branch is discarded. The length pruning includes: comparing the current path hop count with the maximum hop count threshold in real time, and terminating the current traversal branch when the threshold is exceeded; The pruning of duplicate nodes includes: maintaining a global hash table of traversed nodes, and not traversing nodes that have already been traversed a second time.
[0013] In one feasible implementation, when the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, specifically including: The intersection of the forward traversal node set and the reverse traversal node set is calculated in real time. When the intersection is not empty, the corresponding forward path and reverse path are spliced together according to the intersection nodes in the intersection to obtain the global shortest path. After determining the global shortest path, all incomplete traversal branches in the final candidate path tree are destroyed.
[0014] In one feasible implementation, the global shortest path is obtained by concatenating the corresponding forward and reverse paths based on the intersection nodes in the intersection set, specifically including: The graph algorithm is used to merge the forward and reverse paths of the intersection nodes to generate a complete global shortest path. The global shortest path is formatted and a hierarchy marker is added, and then stored in JSON format; The sensitive information in the global shortest path is replaced by a data desensitization function to generate standardized output results.
[0015] On the other hand, embodiments of the present invention also provide a database graph index construction and shortest path acceleration device, the device comprising: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to execute the database graph index construction and shortest path acceleration method.
[0016] Finally, this embodiment of the invention also provides a storage medium, which is a non-volatile computer-readable storage medium storing at least one program, each program including instructions, which, when executed by a terminal, cause the terminal to execute the aforementioned database graph index construction and shortest path acceleration method.
[0017] Compared with the prior art, the database graph index construction and shortest path acceleration method, device and medium provided in this embodiment of the invention have the following beneficial effects: First, this application constructs an adjacency table topology index at the kernel layer, using nodes as index keys to directly record and retrieve the associated edges, adjacent nodes, and relationship types corresponding to nodes. This transforms the acquisition of the node adjacency set from a full table traversal to direct index reading, reducing the time complexity of topology association retrieval. Consequently, it reduces the disk I / O overhead of shortest path queries in large-scale graph scenarios and shortens query latency.
[0018] Second, this application initiates a bidirectional breadth-first synchronous traversal that spreads forward layer by layer from the starting node and backward layer by layer from the ending node, thereby enabling the bidirectional traversal ranges to converge towards each other. This reduces invalid subgraph traversals that are irrelevant to the target, narrows the traversal search space, and reduces the ineffective consumption of CPU computing power and disk I / O. This bidirectional convergence mechanism is expected to significantly compress the search space of traditional unidirectional traversal.
[0019] Third, this application performs multi-level dynamic pruning during the traversal process to filter out loop paths, excessively long paths exceeding the maximum hop count threshold, and duplicate node branches in real time. This reduces the generation of invalid paths from the source, prevents invalid paths from participating in subsequent path comparison and sorting operations, and reduces the redundant computational overhead of the system.
[0020] Fourth, this application compares the node sets of bidirectional traversal in real time. When the bidirectional node sets first intersect, it determines that the current path is the global shortest path and triggers early termination. It does not require a full traversal and then a global sorting and selection. This can avoid query timeouts caused by the time consumption of full traversal in large-scale graph scenarios and meet real-time business needs. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 A flowchart of a database graph index construction and shortest path acceleration method provided in an embodiment of the present invention; Figure 2 An architecture diagram of a database graph index construction and shortest path acceleration system provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a database graph index construction and shortest path acceleration device provided in an embodiment of the present invention. Detailed Implementation
[0022] To enable those skilled in the art to better understand the technical solutions of this invention, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this invention.
[0023] This invention provides a method for constructing a database graph index and accelerating the shortest path, such as... Figure 1 As shown, the database graph index construction and shortest path acceleration method specifically includes steps S101-S106: S101. When writing graph data, build and incrementally update the adjacency table topology index in real time; receive the client's shortest path query request and parse it to extract the query parameters.
[0024] Specifically, this invention is based on a deep modification of the PostgreSQL database kernel and the Apache AGE extension layer. Figure 2 An architecture diagram of a database graph index construction and shortest path acceleration system provided in an embodiment of the present invention is shown below. Figure 2 As shown, this application constructs a four-layer acceleration architecture at the PostgreSQL kernel layer: a kernel storage layer, a topology index acceleration layer, an intelligent traversal pruning layer, and a query parsing output layer. The kernel storage layer, based on the native PostgreSQL storage engine, carries AGE graph data, including nodes, relation edges, and topology attributes, ensuring ACID properties of transactions and data persistence. The topology index acceleration layer embeds a kernel-mode adjacency table topology index, synchronizing graph data additions, deletions, and modifications in real time, replacing the native B+ tree index and providing high-speed topology retrieval capabilities. The intelligent traversal pruning layer integrates a bidirectional synchronous traversal module, a multi-level dynamic pruning module, and a real-time optimal termination module, achieving search space convergence, invalid path filtering, and early termination of retrieval. The query parsing output layer is compatible with native Cypher syntax, parses query parameters, schedules kernel acceleration logic, and standardizes the return of the shortest path query results.
[0025] When the graph data is written for the first time, the corresponding adjacency table topology index is generated in real time in the kernel layer. The adjacency table topology index uses the node as the index key and records the associated edges, adjacent nodes, relationship type and hop count weight of the node.
[0026] As a feasible implementation, when a new node is added to the graph data, a new topological index entry for the corresponding node is simultaneously added to the adjacency list topological index. When a node is deleted from the graph data, the corresponding invalid topological index entry is deleted from the adjacency list topological index. When the attributes of a node or edge in the graph data are updated, the relation attributes and hop count weight information in the corresponding topological index entry are incrementally updated.
[0027] In one embodiment, the adjacency list topology index adopts a hash table structure with node ID as the index key; the index value stores outgoing edge information, incoming edge information, adjacent node ID, relationship type, creation time and hop count weight in an orderly manner, and caches the adjacency data of hot nodes through kernel shared memory.
[0028] Furthermore, upon receiving the client's shortest path query request, the kernel syntax parser, compatible with native syntax, extracts core query parameters such as start node ID, end node ID, maximum hop count, and relational constraints.
[0029] In one embodiment, during the graph data writing phase, a kernel storage layer is first created based on the PostgreSQL native storage engine, the transaction isolation level is set to "serialization," and a unified sequence `graph_id_seq` is created for the graph data table "graph_data." Then, an adjacency table topological index is built, using a hash table structure to store node information, including integer node IDs, varchar(50) relation types, and arrays of adjacency node information. The primary key of the index table `graph_index` is `node_id`, uniquely identifying a node. The index update flag `last_update_time` is set to the current timestamp to achieve incremental update capabilities.
[0030] Then, it receives shortest path query requests from clients, parses the Cypher query statement, and extracts the query parameters. Next, it verifies query permissions and replaces sensitive fields using the `graph_security` view, for example, replacing "relationship type" with "relationship type_code". Finally, it standardizes the query conditions, converting the Cypher statement into an SQL statement.
[0031] This invention overcomes the limitations of existing general-purpose B+ tree indexes by adding a graph topology-specific adjacency index in kernel mode, adapting to the AGE graph data storage structure. Firstly, in the index structure design, the index key is the unique ID of the node, and the value stores all outgoing edges, incoming edges, adjacent node IDs, relationship types, creation times, and hop count weights of the current node in an ordered manner. When nodes or edges are added, deleted, or updated, the kernel incrementally updates the index in real time, eliminating the need for a full rebuild and ensuring strong consistency between the index and the graph data. When querying the topology associated with a node, the adjacency set is directly and accurately read through the index, significantly reducing time complexity. The index uses kernel shared memory to cache the adjacency data of hot nodes, further improving retrieval speed.
[0032] S102. Based on the adjacency list topology index, obtain the forward adjacency set of the starting node and the reverse adjacency set of the ending node.
[0033] Specifically, the kernel layer's topology index fast retrieval interface is called to read all adjacent nodes of the starting node from the adjacency list topology index, forming a forward adjacency set; at the same time, all adjacent nodes of the ending node are read, forming a reverse adjacency set.
[0034] As a feasible implementation method, the kernel topology index fast retrieval interface is called to directly read the forward adjacency set of the starting node and the reverse adjacency set of the ending node, skipping the full table scan process.
[0035] In one embodiment, query conditions are constructed based on node IDs, and the forward adjacency information of the starting node and the reverse adjacency information of the ending node are directly obtained through the index `graph_index`. Then, a query index is built to support fast retrieval based on the relation type "adjacency" and the hop count of 5, using the text index "fulltext" to retrieve relation types.
[0036] S103. Starting from the start node and the end node, perform bidirectional synchronous layer-by-layer traversal of associated nodes in the forward adjacency set and the reverse adjacency set, and perform multi-level dynamic pruning operations on the node advancement path during the traversal process to obtain the forward traversal node set and the reverse traversal node set.
[0037] Specifically, first, the bidirectional traversal queue is initialized and a maximum hop count threshold is set. Then, starting from the starting node, the associated edges and adjacent nodes in the forward adjacency set are traversed in a breadth-first manner to obtain forward candidate paths. The nodes and associated edges contained in the forward candidate paths are stored in the forward traversal queue in the bidirectional traversal queue.
[0038] Meanwhile, starting from the terminating node, the associated edges and adjacent nodes in the reverse adjacency set are traversed in a breadth-first manner to obtain the reverse candidate path; the nodes and associated edges contained in the reverse candidate path are stored in the reverse traversal queue in the bidirectional traversal queue.
[0039] Furthermore, the path association analysis of forward and reverse candidate paths is performed using the adjacency table topological index to construct an initial candidate path tree.
[0040] As a feasible implementation, a bidirectional traversal queue is initialized, with a maximum hop count threshold of 5. Starting from the starting node, a breadth-first search algorithm is used for forward traversal to obtain candidate paths, and intermediate results are stored in the forward traversal queue. Simultaneously, starting from the ending node, a breadth-first search algorithm is used for reverse traversal to obtain reverse paths, and intermediate results are stored in the reverse traversal queue. Then, path association analysis is performed using the adjacency list index to construct a candidate path tree, and a graph algorithm is used to generate all possible path combinations.
[0041] Furthermore, after obtaining the initial candidate path tree, redundant paths are pruned using a multi-level dynamic pruning method to obtain the final candidate path tree. The nodes in the final candidate path tree are then divided into the forward traversal node set and the reverse traversal node set according to the different starting nodes. As a feasible implementation method, the multi-level dynamic pruning method includes loop pruning, length pruning, and duplicate node pruning. Loop pruning includes: recording all visited nodes of a single path during traversal; when a duplicate node appears in the current path, it is determined to be a loop path and the current traversal branch is discarded. Length pruning includes: comparing the current path's hop count with a maximum hop count threshold in real time; terminating the current traversal branch when the threshold is exceeded. Duplicate node pruning includes: maintaining a global traversal node hash table; nodes that have already been traversed are not traversed again.
[0042] In one embodiment, a graph algorithm is used to detect loop paths, and a set of "visited nodes" is used to record the visit status. The path length is checked to see if it is less than or equal to a maximum hop count threshold of 5; if the condition is met, the path is retained; otherwise, it is deleted. A hash table `node_set` is used to record visited nodes, and branches of duplicate nodes are pruned.
[0043] This invention modifies the original unidirectional traversal logic, achieving kernel-level bidirectional convergent retrieval. First, starting from the query's starting node, it traverses forward-connected edges layer by layer, maintaining a set of forward-traversed nodes. Simultaneously, starting from the query's ending node, it traverses backward-connected incoming edges, maintaining a set of backward-traversed nodes. Then, the two traversals proceed synchronously layer by layer, comparing the bidirectional node sets in real time, quickly converging the retrieval range. This significantly reduces the number of traversals of invalid nodes and edges.
[0044] This invention also embeds three-level pruning rules into the kernel traversal path to filter all invalid paths in real time. Loop pruning removes loop paths, length pruning removes excessively long paths, and duplicate node pruning removes secondary traversal paths, eliminating redundant overhead from repeated traversals.
[0045] S104. When the forward traversal node set and the reverse traversal node set intersect, determine the global shortest path based on the intersection node and return the shortest path query result.
[0046] Specifically, the intersection of the forward traversal node set and the reverse traversal node set is calculated in real time.
[0047] When the intersection is not empty, based on the intersection nodes, the corresponding forward and reverse paths are concatenated to obtain the global shortest path, which includes: The global shortest path is generated by merging the forward and reverse paths of nodes that intersect using a graph algorithm. This global shortest path is then formatted, hierarchical markers are added, and it is stored as JSON. A data anonymization function is used to replace sensitive information in the global shortest path, generating a standardized output.
[0048] Furthermore, after determining the global shortest path, all unfinished traversal branches in the final candidate path tree are destroyed.
[0049] As a feasible implementation, the common part of the two traversal queues is calculated using intersection operations. It is then determined whether the intersection `common_part` is empty; if not, it is considered the shortest path. If the intersection is empty, the current traversal depth is recorded as the baseline depth, incomplete branches are marked, and the starting point for the new round of traversal is set to an unvisited node. The traversal continues, expanding the layer until the shortest path is matched or the maximum hop count threshold is reached. Then, a graph algorithm is used to merge the paths in both directions to generate the complete shortest path. The path is formatted, level markers are added, and it is stored in JSON format. Sensitive information is replaced using the data masking function `mask_data`. The result set is sorted by the `distance` field to generate standardized output results.
[0050] In addition, embodiments of the present invention also provide a database graph index construction and shortest path acceleration device, such as... Figure 3 As shown, the database graph index building and shortest path acceleration devices specifically include: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by at least one processor, so that at least one processor can perform the following: When writing graph data, the adjacency table topology index is built and updated incrementally in real time; Receive and parse the shortest path query request from the client, and extract the query parameters; wherein, the query parameters include at least the start node and the end node; Based on the adjacency list topology index, obtain the forward adjacency set of the starting node and the reverse adjacency set of the ending node; Starting from the starting node and the ending node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set. During the traversal, multi-level dynamic pruning operations are performed on the node advancement path to obtain the forward traversal node set and the reverse traversal node set. When the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, and the shortest path query result is returned.
[0051] Finally, this embodiment of the invention also provides a storage medium, which is a non-volatile computer-readable storage medium storing at least one program, each program including instructions, which, when executed by a terminal, cause the terminal to perform: When writing graph data, the adjacency table topology index is built and updated incrementally in real time; Receive and parse the shortest path query request from the client, and extract the query parameters; wherein, the query parameters include at least the start node and the end node; Based on the adjacency list topology index, obtain the forward adjacency set of the starting node and the reverse adjacency set of the ending node; Starting from the starting node and the ending node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set. During the traversal, multi-level dynamic pruning operations are performed on the node advancement path to obtain the forward traversal node set and the reverse traversal node set. When the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, and the shortest path query result is returned.
[0052] The various embodiments in this invention are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and non-volatile computer storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0053] The foregoing has described specific embodiments of the present invention. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0054] The above description is merely an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for constructing a database graph index and accelerating the shortest path, characterized in that, The method includes: When writing graph data, the adjacency table topology index is built and updated incrementally in real time; Receive and parse the shortest path query request from the client, and extract the query parameters; wherein, the query parameters include at least the start node and the end node; Based on the adjacency list topology index, obtain the forward adjacency set of the starting node and the reverse adjacency set of the ending node; Starting from the starting node and the ending node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set. During the traversal, multi-level dynamic pruning operations are performed on the node advancement path to obtain the forward traversal node set and the reverse traversal node set. When the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, and the shortest path query result is returned.
2. The database graph index construction and shortest path acceleration method according to claim 1, characterized in that, When writing graph data, the adjacency table topology index is built and incrementally updated in real time, specifically including: When the graph data is written for the first time, the adjacency table topology index is constructed in real time in the kernel layer; wherein, the adjacency table topology index uses the node as the index key and records the associated edge, adjacent node, relationship type and hop weight of the node; When new data is added to the graph, the corresponding topology index entry for the node in the adjacency table topology index is added synchronously. When a deletion operation occurs in the graph data, the corresponding invalid topological index entry in the adjacency table topological index is deleted; When the attributes of nodes or edges in the graph data are updated, the relation attributes and hop count weight information in the corresponding topological index entries are updated incrementally.
3. The database graph index construction and shortest path acceleration method according to claim 1, characterized in that, The adjacency list topology index adopts a hash table structure with node ID as the index key. The index value stores outgoing edge information, incoming edge information, adjacent node ID, relationship type, creation time and hop count weight in an orderly manner, and caches the adjacency data of hot nodes through kernel shared memory.
4. The database graph index construction and shortest path acceleration method according to claim 1, characterized in that, Based on the adjacency list topology index, the forward adjacency set of the starting node and the reverse adjacency set of the ending node are obtained, specifically including: The kernel layer's topology index fast retrieval interface is invoked to read all adjacent nodes of the starting node from the adjacency list topology index, forming the forward adjacency set; at the same time, all adjacent nodes of the ending node are read to form the reverse adjacency set.
5. The method for constructing a database graph index and accelerating the shortest path according to claim 1, characterized in that, Starting from the start node and the end node, a bidirectional synchronous layer-by-layer traversal of associated nodes is performed in the forward adjacency set and the reverse adjacency set, specifically including: Initialize the bidirectional traversal queue and set the maximum number of jumps threshold; Starting from the starting node, the associated edges and adjacent nodes in the forward adjacency set are traversed in a breadth-first manner to obtain forward candidate paths; the nodes and associated edges contained in the forward candidate paths are stored in the bidirectional traversal queue. Simultaneously, starting from the termination node, the associated edges and adjacent nodes in the reverse adjacency set are traversed in reverse order in a breadth-first manner to obtain the reverse candidate path; the nodes and associated edges contained in the reverse candidate path are stored in the bidirectional traversal queue. The adjacency list topology index is used to perform path association analysis on the forward candidate path and the reverse candidate path to construct an initial candidate path tree.
6. The database graph index construction and shortest path acceleration method according to claim 5, characterized in that, During the traversal, multi-level dynamic pruning operations are performed on the node progression path to obtain the set of nodes traversed in the forward direction and the set of nodes traversed in the reverse direction, specifically including: After obtaining the initial candidate path tree, redundant paths are pruned using a multi-level dynamic pruning method to obtain the final candidate path tree. The nodes in the final candidate path tree are then divided into the forward traversal node set and the reverse traversal node set according to the different starting nodes. The multi-level dynamic pruning method includes loop pruning, length pruning, and repeat node pruning. The loop pruning includes: recording all visited nodes of a single path during traversal; when a duplicate node appears in the current path, it is determined to be a loop path and the current traversal branch is discarded. The length pruning includes: comparing the current path hop count with the maximum hop count threshold in real time, and terminating the current traversal branch when the threshold is exceeded; The pruning of duplicate nodes includes: maintaining a global hash table of traversed nodes, and not traversing nodes that have already been traversed a second time.
7. The database graph index construction and shortest path acceleration method according to claim 6, characterized in that, When the forward traversal node set and the reverse traversal node set intersect, the global shortest path is determined based on the intersection node, specifically including: The intersection of the forward traversal node set and the reverse traversal node set is calculated in real time. When the intersection is not empty, the corresponding forward path and reverse path are spliced together according to the intersection nodes in the intersection to obtain the global shortest path. After determining the global shortest path, all incomplete traversal branches in the final candidate path tree are destroyed.
8. The database graph index construction and shortest path acceleration method according to claim 7, characterized in that, Based on the intersection nodes in the intersection set, the corresponding forward and reverse paths are concatenated to obtain the global shortest path, specifically including: The graph algorithm is used to merge the forward and reverse paths of the intersection nodes to generate a complete global shortest path. The global shortest path is formatted and a hierarchy marker is added, and then stored in JSON format; The sensitive information in the global shortest path is replaced by a data desensitization function to generate standardized output results.
9. A database graph index construction and shortest path acceleration device, characterized in that, The device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to execute a database graph index construction and shortest path acceleration method according to any one of claims 1-8.
10. A storage medium, characterized in that, The storage medium is a non-volatile computer-readable storage medium that stores at least one program, each program including instructions that, when executed by a terminal, cause the terminal to perform a database graph index construction and shortest path acceleration method according to any one of claims 1-8.