Path query method, query device and computer readable storage medium
By establishing affinity edges as the shortest path in the graph database, the problem of slow node path lookup in the graph database is solved, achieving faster query speed and higher query efficiency.
Patent Information
- Application Number
- CN202210369917.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-04-08
AI Technical Summary
When searching for a path between two nodes in a graph database, there are problems such as slow search speed and low search efficiency.
In a graph database, in response to the existence of a connection path between two nodes that meets preset requirements, a proximity edge is established connecting the two nodes as the shortest path, and the proximity edge is used directly during querying to reduce the number of connection edges in the query.
By establishing affinity edges, the degree of graph database queries is reduced, query speed is accelerated, and query efficiency is improved.
Smart Images

Figure CN114911978B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of graph database technology, and in particular to a path query method, query device and computer-readable storage medium. Background Technology
[0002] Graph databases, also known as graph-oriented / graph-based databases, essentially use a graph data structure to store and retrieve data. The main elements in a graph database are nodes and edges. In practical applications, nodes are often used to represent entities or concepts, while edges connecting nodes represent the relationships between them. This graph-based abstract structure easily represents complex relational data, therefore graph databases are widely used in fields such as social networks and power grids.
[0003] Currently, when searching for a path between two nodes in a graph database, there are common problems such as slow search speed and low search efficiency. Summary of the Invention
[0004] This application provides a path query method, query device, and computer-readable storage medium, which can improve query speed.
[0005] A first aspect of this application provides a path query method, the method comprising: in a graph database, in response to the existence of a connection path between two nodes that meets preset requirements, establishing a proximity edge connecting the two nodes as the shortest path between the two nodes; after obtaining two target nodes, querying the graph database for the shortest path between the two target nodes; replacing each proximity edge of the shortest path with at least one corresponding target edge, wherein the information carried by the at least one target edge corresponding to the proximity edge at least characterizes the connection path between the two nodes connected by the proximity edge that meets the preset requirements; and displaying the shortest path between the two target nodes.
[0006] A second aspect of this application provides a query device, which includes a processor, a memory, and a communication circuit. The processor is coupled to the memory and the communication circuit, respectively. The memory stores program data, and the processor executes the program data in the memory to implement the steps in the above method.
[0007] A third aspect of this application provides a computer-readable storage medium storing a computer program that can be executed by a processor to implement the steps in the above-described method.
[0008] The beneficial effects are: the setting of the affinity edge in this application establishes a direct connection between two nodes that meet the preset requirements, which can reduce the degree of graph database queries, speed up the query, and improve the query efficiency. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0010] Figure 1 This is a flowchart illustrating one implementation method of the path query method of this application;
[0011] Figure 2 This is a schematic diagram showing two nodes connected by a relation edge;
[0012] Figure 3 This is a diagram illustrating the connection between two nodes through a relation node;
[0013] Figure 4 This is a schematic diagram showing two nodes connected by a relation edge;
[0014] Figure 5 This is a diagram illustrating the connection between two nodes through a relation node;
[0015] Figure 6 This is a diagram illustrating the establishment of affinity edges between nodes;
[0016] Figure 7 This is a diagram illustrating the establishment of affinity edges between nodes;
[0017] Figure 8 This is a diagram illustrating the shortest path in an application scenario;
[0018] Figure 9 This is a diagram illustrating the shortest path in another application scenario;
[0019] Figure 10 This is a schematic diagram of one embodiment of the query device of this application;
[0020] Figure 11 This is a schematic diagram of another embodiment of the query device of this application;
[0021] Figure 12 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0022] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0023] First, it should be noted that the path query method of this application is executed by a query device, and the graph database can be stored on the query device or on a storage device that can communicate with the query device.
[0024] The degree referred to below refers to the number of connecting edges. For example, if a connecting path includes one connecting edge, the degree of the connecting path is one; if a connecting path includes two connecting edges, the degree of the connecting path is two.
[0025] See Figure 1 , Figure 1 This is a flowchart illustrating one embodiment of the path query method of this application. The method includes:
[0026] S110: In the graph database, in response to the existence of a connection path between two nodes that meets the preset requirements, establish a proximity edge connecting the two nodes as the shortest path between the two nodes.
[0027] Specifically, if there is a connection path between two nodes that meets the preset requirements, then an affinity edge is established between the two nodes. At this time, the shortest path between the two nodes is the affinity edge, and the degree of the shortest path is one, that is, a direct connection between the two nodes is established.
[0028] In a graph database, in response to the existence of a relational edge connecting two nodes, or the existence of a preset relational node connecting two nodes, a connection path that meets the preset requirements is determined to exist between the two nodes.
[0029] Specifically, in combination Figure 2 In graph databases, the relationship between two nodes is typically stored as a connection between a node and a target node via a relation edge. This relation edge represents the relationship between the two nodes. However, since the data types stored on relation edges are much fewer than those stored on nodes, this method becomes insufficient when more information needs to be stored on the relation edge. Therefore, nodes are needed to store more information. In other words, when it is necessary to expand the information on a relation edge, nodes can be used for expansion. This involves setting up a connection between two nodes via a relation node, and then setting up more extension relation nodes connected to the relation node to expand the relationship between the two nodes. Figure 3 As shown.
[0030] To better understand, here we combine Figure 4 and Figure 5 To illustrate with examples:
[0031] exist Figure 4 The example shows a peer relationship between person A and person B, but it doesn't display much more information about peers, such as the time, method, and location of their travels. Therefore, in an expanded graph database, such as... Figure 5 As shown, person A and person B are connected through the "Trainee" relationship node. This "Trainee" relationship node is further connected to multiple extended relationship nodes such as "Time," "Location," and "Train Number." Therefore, from... Figure 5 It can be seen that personnel A and personnel B traveled together at what time, in what place, and using what batch of transportation.
[0032] In the graph database of this embodiment, two nodes can be connected by either a relation edge or a relation node. A relation node can be connected to one or more extended relation nodes, or it can be not connected to any extended relation nodes. Furthermore, two nodes can be connected by both a relation edge and a relation node.
[0033] In this embodiment, if two nodes are connected by a relational edge, or by a preset relational node, or by both a relational edge and a preset relational node, then a proximity score is established between the two nodes to serve as the shortest path between them.
[0034] In this process, a preset number of relationship nodes are set as preset relationship nodes. The preset number can be one, two, or more. The preset relationship nodes are finite and enumerable, meaning that the number of preset relationship nodes is finite, and all of the preset number of preset relationship nodes can be enumerated.
[0035] In this embodiment, when establishing an affinity edge between two nodes that meet preset requirements, only one affinity edge will be established between these two nodes, such as... Figure 6 As shown, the direction and identifier of the intimacy edge are all unique.
[0036] After proposing an affinity edge between two nodes, the shortest path between these two nodes only includes one connecting edge. When you want to query the shortest path, if there is an affinity edge connecting the two nodes, you can directly use that affinity edge as the shortest path between the two nodes, without having to obtain the original relationship between the two nodes. This can speed up the query and improve the query efficiency.
[0037] It should be noted that the creation of affinity edges does not affect the original relationship between two nodes stored in the graph database. The creation of affinity edges simply adds a special type of connection edge to the original data in the graph database.
[0038] In this embodiment, in order to reduce the amount of data storage, only preset information is stored in the affinity edge between two nodes. This preset information is used to distinguish the affinity edge from other types of connection edges. That is, the affinity edge only stores basic information to prove that its type is an affinity edge, and does not store other redundant information.
[0039] It should be noted that in other implementations, when storage is not a concern, the affinity edge can also store information carried by the connection path between two nodes that meets preset requirements.
[0040] S120: After obtaining two target nodes, query the graph database for the shortest path between the two target nodes.
[0041] When a user wants to know the connection path between two target nodes, they input the two target nodes, and then the query device retrieves the two target nodes and queries the graph database for the shortest path between the two target nodes.
[0042] Users can input two target nodes on the front-end device connected to the query device, or they can input two target nodes directly on the query device, which is equivalent to the query device integrating a front-end device.
[0043] Since step S110 establishes an affinity edge between two nodes whose original relationship meets the preset requirements as the shortest path between the two nodes, step S120 can reduce the number of connection edges queried when querying the shortest path between two target nodes, thereby speeding up the query and improving the efficiency of the query.
[0044] In this embodiment, when querying the shortest path between two target nodes, the system first queries whether the two target nodes can be reached directly at the first degree. If they can be reached directly, the query stops and the found connection path is returned. If they cannot be reached directly, the system queries whether the two target nodes can be reached at the second degree. If they can be reached, the system stops and the found connection path is returned. If they cannot be reached, the system queries whether the two target nodes can be reached at the third degree, and so on.
[0045] In other application scenarios, when querying the shortest path, it is not necessary to start the query from the first degree, but from a pre-set degree, such as the second degree or the fourth degree, depending on the actual needs.
[0046] In other words, the steps to find the shortest path between two target nodes may include:
[0047] (a1) Find the connection path between two target nodes with the number of connecting edges equal to the initial number.
[0048] (b1) If a connection path with the same number of edges as the initial number is found, then the found connection path is taken as the shortest path.
[0049] (c1) If no connection path with the number of connected edges is found, increment the initial number by one and return to step (a1).
[0050] The initial quantity at the beginning of execution can be 1, or other values set according to actual needs.
[0051] To avoid the algorithm continuously searching indefinitely, considering that there might be no connection path between two target nodes, this implementation also sets a quantity threshold. Specifically, after failing to find a connection path with the initial number of connections, it checks whether the initial number exceeds the threshold. If it does not exceed the threshold, the initial number is incremented by one, and the algorithm returns to search for a connection path between the two target nodes with the initial number of connections. However, if the initial number exceeds the threshold, an alarm is triggered directly, and subsequent steps are not executed. The alarm processing method can include at least one of text prompts, sound prompts, and brightness prompts.
[0052] In other implementations, the process of finding the shortest path between two target nodes can also be: first, find all the connection paths between the two target nodes, and then, among all the found connection paths, determine the shortest path with the fewest connecting edges.
[0053] S130: Replace each affinity edge of the shortest path with at least one corresponding target edge, wherein the information carried by the at least one target edge corresponding to the affinity edge at least represents the connection path between the two nodes connected by the affinity edge that meets the preset requirements.
[0054] In order to show the user the original relationship between the two target nodes, it is also necessary to replace each of the affinity edges in the shortest path with at least one target edge of its corresponding value.
[0055] In one application scenario, the information carried by at least one target edge corresponding to the intimacy edge only represents the connection path between the two nodes connected by the intimacy edge that meets the preset requirements. In other application scenarios, the information carried by at least one target edge corresponding to the intimacy edge represents all the original connection paths between the two nodes connected by the intimacy edge. That is, at this time, the information carried by at least one target edge represents all the connection paths between the two nodes in the graph database before the intimacy edge was established.
[0056] To ensure consistency between the degree in the graph database and the degree in the display layer (display device), the affinity edges in the shortest path are replaced with at least one parallel target edge. In other words, after the replacement, the first and second nodes connected by affinity edges in the shortest path are either connected by one target edge or by two or more parallel target edges. As a result, the degree of the shortest path between the first and second nodes remains one degree when displayed later.
[0057] In this embodiment, step S130 specifically includes: obtaining the connection path between the first node and the second node connected by each intimacy edge that meets the preset requirements; determining the target edge corresponding to each connection path that meets the preset requirements, and obtaining at least one target edge corresponding to each intimacy edge, wherein the information carried by the target edge corresponding to the connection path that meets the preset requirements represents the connection path; and replacing each intimacy edge with at least one corresponding parallel target edge.
[0058] Specifically, for each intimacy edge, the following processing is performed:
[0059] First, find all connection paths between the first and second nodes connected by the affinity edge that meet the preset requirements. Then, for each connection path that meets the preset requirements, generate a corresponding target edge. The target edge corresponding to the connection path that meets the preset requirements carries the information of the connection path. That is, when establishing an affinity edge between two nodes, if only one connection path between the two nodes meets the preset requirements, then step S130 replaces the affinity edge with a target edge; if two connection paths between the two nodes meet the preset requirements, then step S130 replaces the affinity edge with two target edges.
[0060] In this context, regardless of whether a single affinity edge corresponds to two, three, or more target edges, multiple target edges are in a parallel relationship between the first node and the second node.
[0061] In this embodiment, the process of finding at least one target edge corresponding to an affinity edge includes:
[0062] (a2) In response to the existence of a relation edge between two nodes connected by the intimacy edge, set the target edge corresponding to the intimacy edge to include all relation edges connecting the two nodes.
[0063] Specifically, in a graph database, if there is a relational edge connecting the first node and the second node connected by the affinity edge, then at least one target edge is set to include all relational edges connecting the first node and the second node.
[0064] (b2) In response to the existence of a preset relationship node between two nodes connected by the intimacy edge, the target edge corresponding to the intimacy edge is set to include the multi-information edge corresponding to each of the preset relationship nodes, wherein the multi-information edge corresponding to each of the preset relationship nodes carries the information of the preset relationship node and the information of all extended nodes connected to the preset relationship node.
[0065] Specifically, in the graph database, if the first and second nodes connected by the affinity edge are connected by a preset relationship node, then the connection paths of each preset relationship node are merged. The specific process is as follows:
[0066] For each preset relation node, establish a multi-information edge connecting the first node and the second node. It can be understood that the number of multi-information edges is equal to the number of preset relation nodes, and when there are more than two multi-information edges, the two or more multi-information edges are in a parallel relationship.
[0067] Each multi-information edge carries information including the information carried by the corresponding preset relationship node itself, as well as the information carried by all extended relationship nodes connected to the corresponding preset relationship node.
[0068] For ease of connection, this is combined here. Figure 7 Explanation:
[0069] exist Figure 7 In the diagram, solid lines represent the original relationships between people. Based on the aforementioned principles for establishing intimacy, an intimacy edge is established between person A and person B, denoted as intimacy edge 1, and an intimacy edge is established between person B and person C, denoted as intimacy edge 2.
[0070] When the two target nodes are person A and person C, the first step is to query whether person A and person C are reachable at a degree of 1. Obviously, from this... Figure 7 It can be seen that it is not reachable at degree 1. Then, a query is made to see if it is reachable at degree 2. Figure 7 It can be seen that personnel A and personnel C are reachable at a degree of 2, and the shortest path includes two intimacy edges.
[0071] After finding the shortest path, replace the two affinity edges with their corresponding target edges. For affinity edge 1, since there are two relationship edges and two preset relationship nodes connecting person A and person B (assuming the relationship nodes of traveling on the same plane and traveling on the same train are preset relationship nodes), then affinity edge 1 is replaced with four target edges, including two relationship edges and two multi-information edges, such as... Figure 8As shown, multi-information edge 1 corresponds to the preset relationship node "flying together," carrying information about "flying together" and all extended relationship nodes connected to "flying together," such as "train number" and "time." Multi-information edge 2 corresponds to the preset relationship node "carrying together," carrying information about "carrying together" and all extended relationship nodes connected to "carrying together," such as "train number" and "time." Regarding intimacy edge 2, since there is only one relationship edge connecting person B and person C, intimacy edge 2 is replaced with the relationship edge between person B and person C. Figure 8 As shown. Among them Figure 7 The structure diagram shown is the graph stored in the graph database, and Figure 8 What is shown is the shortest path graph that is ultimately presented to the user.
[0072] exist Figure 7 and Figure 8 In the example, "riding in a car together" and "riding on a plane together" are both preset relationship nodes. However, when only "riding on a plane together" is a preset relationship node, and "riding in a car together" is not, the established intimacy edge still behaves as before. Figure 7 As shown, but the shortest path ultimately displayed at this point is as follows: Figure 9 As shown, since the relationship of "riding in the same car" between person A and person B does not meet the preset requirements, no target edge carrying this relationship will be generated in the end.
[0073] Since graph databases allow direct querying of the two nodes connected by a relation edge, all relation edges corresponding to intimacy can be retrieved directly. The process of querying multi-information edges corresponding to intimacy edges is described below:
[0074] (a3) Get the types of the first and second nodes connected to the intimacy edge.
[0075] The type of node can be a vehicle, a person, or an animal, etc.
[0076] (b3) Determine the preset relationship node corresponding to the intimacy edge based on the type of the first node and the second node.
[0077] Based on the type of node, it can be preliminarily determined which preset relationship nodes the first node may be connected to the second node.
[0078] For example, the preset relationship nodes include four relationship nodes: driving, traveling together, colleagues, and dining together. However, the first node and the second node are both people. Therefore, the first node and the second node can only be connected through the preset relationship nodes such as "traveling together", "colleagues", and "dining together".
[0079] (c3) Search for the corresponding preset relationship node among the preset relationship nodes connected to the first node.
[0080] Using the example above as an example: Suppose that the preset relationship nodes connected to the first node include the three nodes "driving", "flying together", and "dining together", then in these three nodes, we search for the three preset relationship nodes "flying together", "colleagues", and "dining together" found in step (b2). In the end, we can only search for the two preset relationship nodes "flying together" and "dining together".
[0081] (d3) Among the found preset relationship nodes, find the preset relationship node that is connected to the second node.
[0082] Using the example above as an example: at this point, we only need to traverse the two preset relationship nodes, "flying together" and "dining together", and determine whether they are connected to the second node.
[0083] The above method allows for a quick and efficient query of all preset relational nodes connecting the first node and the second node.
[0084] In other implementations, without considering processing speed and computational load, it is also possible to traverse all preset relationship nodes connected to the first node and find all preset relationship nodes connected to the second node. Using the example above as an illustration: in this case, it is necessary to traverse the three nodes "driving," "flying together," and "dining together" connected to the first node, and sequentially determine whether they are connected to the second node.
[0085] (e3) For each preset relationship node, integrate the information of the preset relationship node with the information of all connected extended nodes to obtain the integrated information corresponding to each preset relationship node.
[0086] If no preset relationship node is found that connects to the second node, it means that there is no need to establish a multi-information edge between the first node and the second node. If a preset relationship node that connects to the second node is found, the information of the preset relationship node and all its connected extended nodes are integrated to obtain integrated information.
[0087] (f3) For each preset relation node, generate a multi-information edge that connects the first node and the second node and carries the corresponding integration information.
[0088] For each preset relationship node, generate a multi-information edge carrying the corresponding integrated information.
[0089] When there are multiple affinity edges in the shortest path, different threads can be used to simultaneously search for the corresponding target edge for multiple affinity edges, so as to speed up the processing and improve the processing efficiency.
[0090] It is understandable that when the shortest path does not have an affinity edge, step S140 is executed after step S120.
[0091] S140: Display the shortest path between two target nodes.
[0092] Finally, the shortest path between the two target nodes is displayed to the user.
[0093] As can be seen from the above, the setting of the affinity edge in this application establishes a direct connection between two nodes that meet the preset requirements, which can reduce the degree of graph database queries, speed up the query, and improve the query efficiency.
[0094] The present application has described the solution using the above embodiments, but the present application is not limited thereto.
[0095] For example, in other implementations, the criteria for determining whether there is a connection path between two nodes that meets the preset requirements can also be other. For example, an affinity edge is established between two nodes only when there are two preset relationship nodes between them, or an affinity edge is established between two nodes only when they are connected through preset relationship nodes, or an affinity edge is established between two nodes only when they are connected through preset relationship edges.
[0096] Alternatively, when replacing the intimacy edge with the target edge, you can set the intimacy edge to always correspond to only one target edge. The information carried by the target edge represents all connection paths between the two nodes that meet the preset requirements, or represents all connection paths between the two nodes before the intimacy edge is established.
[0097] Alternatively, without considering the consistency between the degree in the graph database and the degree in the presentation layer, when replacing the affinity edge with at least one target edge, one can directly replace the affinity edge with all connection paths between the two nodes before the affinity edge was established, or connection paths that meet the preset requirements.
[0098] See Figure 10 , Figure 10 This is a schematic diagram of one embodiment of the query device of this application. The query device 200 includes a processor 210, a memory 220, and a communication circuit 230. The processor 210 is coupled to the memory 220 and the communication circuit 230 respectively. The memory 220 stores program data. The processor 210 executes the program data in the memory 220 to implement the steps in any of the above embodiments. The detailed steps can be found in the above embodiments and will not be repeated here.
[0099] The query device 200 can be any device with algorithm processing capabilities, such as a computer or a mobile phone, and there are no restrictions on it.
[0100] See Figure 11 , Figure 11 This is a schematic diagram of another embodiment of the query device of this application. The query device 300 includes a creation module 310, a query module 320, a replacement module 330, and a display module 340.
[0101] The module 310 is used in the graph database to establish a proximity edge connecting two nodes in response to the existence of a connection path between two nodes that meets preset requirements, so as to serve as the shortest path between the two nodes.
[0102] The query module 320 is connected to the establishment module 310 and is used to query the shortest path between the two target nodes in the graph database after obtaining the two target nodes.
[0103] The replacement module 330 is connected to the query module 320 and is used to replace each affinity edge of the shortest path with at least one corresponding target edge. The information carried by the at least one target edge corresponding to the affinity edge at least represents the connection path between the two nodes connected by the affinity edge that meets the preset requirements.
[0104] Display module 340 is connected to replacement module 330 and is used to display the shortest path between two target nodes.
[0105] When the query device 300 is working, it executes the method steps of any of the above embodiments. For detailed steps, please refer to the above embodiments, which will not be repeated here.
[0106] The query device 300 can be any device with algorithm processing capabilities, such as a computer or a mobile phone, and there are no restrictions on it.
[0107] See Figure 12 , Figure 12 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 400 stores a computer program 410, which can be executed by a processor to implement the steps in any of the above methods.
[0108] Specifically, the computer-readable storage medium 400 can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or a device that can store the computer program 410. Alternatively, it can be a server that stores the computer program 410, which can send the stored computer program 410 to other devices for execution, or it can run the stored computer program 410 itself.
[0109] The above description is merely an embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A path query method, characterized by, The method comprises: In the graph database, in response to the existence of a connection path between two nodes satisfying a preset requirement, an affinity edge connecting the two nodes is established as a shortest path between the two nodes, and the degree of the shortest path is one; wherein, in the graph database, in response to the existence of a relationship edge connecting two nodes, or the existence of a preset relationship node connecting the two nodes, it is determined that there is a connection path between the two nodes satisfying the preset requirement; After obtaining two target nodes input by a user, the shortest path between the two target nodes is queried in the graph database, comprising: finding a connection path between the two target nodes with an initial number of connection edges; if a connection path with the initial number of connection edges is queried, the queried connection path is taken as the shortest path; if a connection path with the initial number of connection edges is not queried, the initial number is increased by one, and the step of finding a connection path between the two target nodes with an initial number of connection edges is executed again, wherein the initial number is one; Each affinity edge existing in the shortest path is replaced by at least one target edge corresponding to the affinity edge respectively, wherein the at least one target edge corresponding to the affinity edge carries information representing at least a connection path between two nodes connected by the affinity edge satisfying the preset requirement; The shortest path is displayed between the two target nodes.
2. The method of claim 1, wherein, The step of replacing each affinity edge existing in the shortest path by at least one target edge corresponding to the affinity edge respectively comprises: A connection path between a first node and a second node connected by each affinity edge satisfying the preset requirement is obtained; The target edge corresponding to each connection path satisfying the preset requirement is determined, and at least one target edge corresponding to each affinity edge is obtained, wherein the target edge corresponding to the connection path satisfying the preset requirement carries information representing the connection path; Each affinity edge is replaced by at least one target edge corresponding to the affinity edge respectively.
3. The method of claim 1, wherein, Before the step of replacing each affinity edge existing in the shortest path by at least one target edge corresponding to the affinity edge respectively, the method further comprises: In response to the existence of the relationship edge between the two nodes connected by the affinity edge, the at least one target edge corresponding to the affinity edge comprises all the relationship edges connected between the two nodes; In response to the existence of the preset relationship node between the two nodes connected by the affinity edge, the at least one target edge corresponding to the affinity edge comprises a plurality of information edges corresponding to the preset relationship node respectively, wherein the plurality of information edges corresponding to the preset relationship node respectively carry information of the preset relationship node and information of all extended nodes connected by the preset relationship node.
4. The method of claim 3, wherein, Before the step of replacing each affinity edge existing in the shortest path by at least one target edge corresponding to the affinity edge respectively, the method further comprises: For each affinity edge in the shortest path, the following processing is performed respectively: Acquiring types of a first node and a second node connected by the closeness edge; According to the types of the first node and the second node, determining a preset relationship node corresponding to the closeness edge; In the preset relationship nodes connected by the first node, searching for a preset relationship node corresponding to the second node; In the searched preset relationship node, searching for a preset relationship node connected by the second node; According to each preset relationship node, integrating information of the preset relationship node and information of all extended nodes connected by the preset relationship node to obtain integrated information corresponding to each preset relationship node; According to each preset relationship node, generating a multi-information edge for connecting the first node and the second node and carrying the corresponding integrated information.
5. The method of claim 1, wherein, The closeness edge only carries preset information, and the preset information is used to represent a type of the closeness edge.
6. The method of claim 1, wherein, Before the step of adding one to the initial number, the method further comprises: Judging whether the initial number exceeds a number threshold value; If the initial number does not exceed the number threshold value, performing the step of adding one to the initial number; If the initial number exceeds the number threshold value, performing alarm processing.
7. A query device, characterized in that The query device comprises a processor, a memory and a communication circuit, the processor is respectively coupled to the memory and the communication circuit, the memory stores program data, and the processor executes the program data in the memory to realize steps in the method according to any one of claims 1-6.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program can be executed by the processor to realize steps in the method according to any one of claims 1-6.
Citation Information
Patent Citations
Power grid graph database query method and device
CN109634987A