CN108573001B - Method and apparatus for determining shortest path distance - Google Patents

Method and apparatus for determining shortest path distance Download PDF

Info

Publication number
CN108573001B
CN108573001B CN201710151247.7A CN201710151247A CN108573001B CN 108573001 B CN108573001 B CN 108573001B CN 201710151247 A CN201710151247 A CN 201710151247A CN 108573001 B CN108573001 B CN 108573001B
Authority
CN
China
Prior art keywords
graph
pair
sub
node
jth
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710151247.7A
Other languages
Chinese (zh)
Other versions
CN108573001A (en
Inventor
张晓飞
刘潭义
颜友亮
陈雷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN201710151247.7A priority Critical patent/CN108573001B/en
Publication of CN108573001A publication Critical patent/CN108573001A/en
Application granted granted Critical
Publication of CN108573001B publication Critical patent/CN108573001B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the application provides a method and a device for determining shortest path distance, wherein the method comprises the following steps: determining a target graph pair corresponding to a first node and a second node, wherein the target graph pair comprises a first sub-graph and a second sub-graph, the first node is a node in the first sub-graph, the second node is a node in the second sub-graph, and the sum of the diameters of the two sub-graphs in the target graph pair is less than or equal to epsilon · s, wherein epsilon is an error value of a preset shortest path distance, and s is a graph distance between the first sub-graph and the second sub-graph; determining a shortest path distance between the first node and the second node as: a sum of a graph pitch between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph. In the embodiment of the application, the error between the determined shortest path distance and the actual shortest path distance is within the control range, which is beneficial to accurately determining the shortest path distance between two nodes.

Description

Method and apparatus for determining shortest path distance
Technical Field
The present application relates to the field of data processing, and more particularly, to a method and apparatus for determining shortest path distance.
Background
With the development of information technology, data processing technology has also been rapidly developed. To facilitate data processing, concrete practical issues are often abstracted into the structure of graphs in graph theory. Determining shortest path distances between nodes is a fundamental operational requirement in graph applications.
The conventional method for determining the shortest path is to select a node set S irrelevant to query in a graph, calculate and store a single-source shortest path of each node in the S, quickly find local landmark points of given two nodes by using Depth First Search (DFS), and determine the shortest path distance between the two nodes according to the local landmark points.
The error between the shortest path distance between two nodes and the actual shortest path distance between two nodes obtained by the method is uncontrollable, and the method is not beneficial to accurately determining the shortest path distance between two nodes.
Disclosure of Invention
The application provides a method and a device for determining shortest path distance, wherein the error between the shortest path distance between two nodes and the actual shortest path distance is within a control range, and the method and the device are favorable for accurately determining the shortest path distance between the two nodes.
In a first aspect, a method for determining shortest path distance is provided, a target graph pair corresponding to a first node and a second node is determined, the target graph pair includes a first subgraph and a second subgraph, the first node is a node in the first subgraph, the second node is a node in the second subgraph, and the sum of diameters of the two subgraphs in the target graph pair is less than or equal to s · s, where e is an error value of a preset shortest path distance, and s is a graph distance between the first subgraph and the second subgraph; determining a shortest path distance between the first node and the second node as: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph.
For ease of explanation, a processor may be the subject of execution of the methods of the present application. In this scheme, d(u,v)=s(g(u),g(v))+lg(u)+lg(v)Wherein d is(u,v)For determining the shortest path distance, s, between a first node and a second node(g(u),g(v))Is the graph spacing, l, between the first sub-graph and the second sub-graphg(u)Is the diameter of the first subgraph,/g(v)The diameter of the second sub-figure.
Figure BDA0001245639470000011
Is the actual shortest path distance between the first node and the second node, since
Figure BDA0001245639470000012
Figure BDA0001245639470000013
Can be pushed out
Figure BDA0001245639470000014
Figure BDA0001245639470000015
The difference between the shortest path distance determined by the method of the present application and the actual shortest path distance is less than or equal to
Figure BDA0001245639470000016
The error between the (estimated) shortest path distance determined by the method and the actual shortest path distance is within the control range, and the method is favorable for accurately determining the shortest path distance between two nodes.
In a possible implementation manner of the first aspect, the first node and the second node belong to nodes in a first graph; the determining of the target graph pair corresponding to the first node and the second node includes: obtaining a plurality of second graph pairs of the first graph, wherein the ith second graph pair in the plurality of second graph pairs comprises a first subgraph and a second subgraph, all subgraphs of the plurality of second graph pairs belong to the first graph, and the sum of the diameters of the two subgraphs of the ith second graph pair is less than or equal to epsilon-siWherein s isiThe graph spacing of two subgraphs of the ith second graph pair is the graph spacing of any one of the second graph pairs; and determining a target graph pair corresponding to the first node and the second node from the plurality of second graph pairs.
In this scheme, the first graph may be split according to the error value, and a plurality of second graph pairs of the first graph may be obtained. The scheme is beneficial to accurately determining the path distance between any two nodes in the first graph, and the method is simple to operate and easy to implement.
In a possible implementation manner of the first aspect, a diameter of a first subgraph of the ith second graph pair is greater than or equal to a diameter of a second subgraph of the ith second graph pair, and the ith second graph pair is greater than or equal to a splitting threshold of the ith second graph pair, where a splitting threshold λ of the ith second graph pairiComprises the following steps: lambda [ alpha ]i=2(1+ε)·li-maxA,/epsilon; wherein li-maxIs the ithDiameter of the first sub-graph of the second graph pair.
In a possible implementation manner of the first aspect, the obtaining a plurality of second graph pairs of the first graph includes: and according to the error value, obtaining a plurality of second graph pairs of the first graph by splitting the first graph.
The processor can acquire a plurality of second graph pairs by splitting the first graph, and the scheme is simple to operate and easy to implement.
In a possible implementation manner of the first aspect, the obtaining, according to the error value, a plurality of second graph pairs of the first graph by splitting the first graph includes: inputting two first graphs into a first set as a graph pair to be disassembled; performing the following operations on the graph pairs to be disassembled in the first set: if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is less than or equal to epsilon · sjInputting the jth graph pair to be disassembled into a second set, wherein sjThe graph distance of two sub-graphs in the jth second graph pair is obtained; if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is larger than epsilon · sjSplitting a first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph, inputting a graph pair to be split, which is composed of the third sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, and inputting a graph pair to be split, which is composed of the fourth sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, wherein the diameter of the first sub-graph of the jth graph pair to be split is greater than or equal to the diameter of the second sub-graph of the jth graph pair to be split; determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
Through the scheme, a plurality of second graph pairs of the first graph can be obtained, and the scheme is simple to operate and easy to implement. Furthermore, the first subgraph with larger diameter is split, so that the splitting times can be reduced, and the multiple second graph pairs can be efficiently and quickly acquired.
Possible implementations of the first aspectIn the above, obtaining a plurality of second graph pairs of the first graph by splitting the first graph according to the error value includes: inputting two first graphs into a first set as a graph pair to be disassembled; performing the following operations on the graph pairs to be disassembled in the first set: if the graph distance of two sub-graphs of the jth graph pair to be disassembled in the first set is greater than or equal to 2(1+ epsilon) · lj-maxInputting the jth graph pair to be disassembled into a second set, wherein lj-maxThe diameter of a first sub-graph of the jth graph pair to be disassembled is larger than or equal to the diameter of a second sub-graph of the jth graph pair to be disassembled; if the graph distance between two sub-graphs of the jth graph pair to be disassembled in the first set is less than 2(1+ epsilon) · lj-maxSplitting a first subgraph of the jth graph pair to be split into a third subgraph and a fourth subgraph, inputting a graph pair to be split consisting of the third subgraph and a second subgraph of the jth graph pair to be split into the first set, and inputting a graph pair to be split consisting of the fourth subgraph and a second subgraph of the jth graph pair to be split into the first set, wherein the diameter of the first subgraph of the jth graph pair to be split is larger than or equal to that of the second subgraph of the jth graph pair to be split; determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
Through the scheme, a plurality of second graph pairs of the first graph can be obtained, and the scheme is simple to operate and easy to implement. Furthermore, the first subgraph with larger diameter is split, so that the splitting times can be reduced, and the multiple second graph pairs can be efficiently and quickly acquired.
In a possible implementation manner of the first aspect, the splitting the first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph includes: splitting the first subgraph of the jth graph pair to be disassembled into a third subgraph and a fourth subgraph according to the diameter of the first subgraph of the jth graph pair to be disassembled.
In the scheme, the first sub-graph is split according to the diameter of the first sub-graph, so that the splitting times can be reduced, and the multiple second graph pairs can be efficiently and quickly acquired.
In a possible implementation manner of the first aspect, before the obtaining, according to the error value, a plurality of second graph pairs of the first graph by splitting the first graph, the method further includes: acquiring an original graph; and generating a minimum spanning tree of the original graph, wherein the first graph is the minimum spanning tree.
In the scheme, the minimum spanning tree of the original graph is split to obtain the plurality of second graph pairs, and the scheme is favorable for efficiently obtaining the plurality of second graph pairs.
In a possible implementation manner of the first aspect, a lookup table of the first graph is obtained, where the lookup table includes correspondence between a plurality of second graph pairs and a plurality of distance values, and a distance value corresponding to an ith second graph pair is equal to a sum of a graph distance between two of the ith second graph pair, a diameter of a first sub-graph of the ith second graph pair, and a diameter of a second sub-graph of the ith second graph pair; the determining, from the plurality of second graph pairs, a target graph pair corresponding to the first node and the second node includes: determining a target graph pair corresponding to the first node and the second node from the lookup table, wherein the determination of the shortest path distance between the first node and the second node is as follows: the sum of the graph spacing s between the first sub-graph and the second sub-graph, the diameter of the first sub-graph, and the diameter of the second sub-graph, comprises: and determining the shortest path distance between the first node and the second node as a distance value corresponding to the target graph pair.
In the scheme, the second path distance between the first node and the second node can be quickly obtained through table lookup, and the shortest path distance between the first node and the second node can be quickly determined.
In a second aspect, an apparatus for determining a shortest path is provided for performing the method of the first aspect or any of the possible implementations of the first aspect, and in particular, the apparatus may include means for performing the method of the first aspect or any of the possible implementations of the first aspect.
In a third aspect, a device for determining a shortest path is provided, where the device includes a processor configured to support the device to perform corresponding functions in the first aspect or any possible implementation manner of the first aspect. The device may also include a memory coupled to the processor that retains program instructions and data necessary for the device.
In a fourth aspect, there is provided a computer readable medium storing program code for execution by a computing device, the program code comprising instructions for performing the method of the first aspect.
According to the technical scheme provided by the application, the error between the determined (namely estimated) shortest path distance and the actual shortest path distance between the two nodes is within the control range, and the method and the device are favorable for accurately determining the shortest path distance between the two nodes.
Drawings
Fig. 1 is a schematic structural diagram of drawing data.
Fig. 2 is a schematic flow chart of an example of a method for determining shortest path distance according to an embodiment of the present application.
Fig. 3 is a schematic flow chart of another example of a method for determining shortest path distance according to an embodiment of the present application.
FIG. 4 is a schematic flow chart diagram of a method for processing graph data according to an embodiment of the present application.
Fig. 5 is a schematic structural diagram of an apparatus for determining a shortest path distance according to an embodiment of the present application.
Fig. 6 is a schematic structural diagram of an apparatus for determining a shortest path distance according to an embodiment of the present application.
Detailed Description
The technical solution in the present application will be described below with reference to the accompanying drawings.
It should be understood that the term "and/or" in the embodiments of the present application is only one kind of association relation describing an associated object, and means that three kinds of relations may exist. For example, a and/or B, may represent: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should also be understood that the division of the modes in the embodiments of the present application is merely for convenience of description, and should not be construed as a particular limitation, and features in various modes may be combined without contradiction.
It should also be understood that "first" and "second" in the embodiments of the present application are used for distinction only and do not represent the meanings of order or size.
A graph in graph theory is a technique for representing graph information using the structure and attributes of the graph. The graph in graph theory includes nodes and edges for connecting the nodes. For ease of illustration, the graphs in the graph theory may be referred to as "graph data". Fig. 1 is a schematic structural diagram of drawing data. As shown in fig. 1, a certain node in the graph data may represent a place, and an edge in the graph may be used to represent a relationship between two nodes.
Graph data comprising a plurality of nodes may be split into a plurality of subgraphs, each subgraph comprising a portion of the nodes of the graph data. Still taking fig. 1 as an example, the graph data ABCDEFG is split to obtain a sub-graph ADF and a sub-graph BCEG.
The diameters of the plots in the plot data are: the distance between the two nodes that are the farthest away in the graph data. For example, sub-graph ADF has a diameter of 11 and sub-graph BCEG has a diameter of 16.
Graph spacing between two graphs in graph data is: shortest path distance between the two graphs. For example, the graph pitch between sub-graph ADF and sub-graph BCEF is 7.
It should be understood that the first graph, the second graph, the sub-graph, and the like in the present application are graph data.
Hereinafter, a method for determining a shortest path distance according to an embodiment of the present application is described in detail with reference to fig. 2 to 4. Fig. 2 is a schematic flow chart of an example of a method for determining shortest path distance according to an embodiment of the present application. Specifically, the method of the embodiment of the present application may be executed by a processor, or may be executed by other apparatuses, and the following describes the present application by taking the processor to execute the method of the embodiment of the present application as an example, as shown in fig. 2, the method 100 includes:
and S110, determining a target graph pair corresponding to the first node and the second node.
The target graph pair comprises a first subgraph and a second subgraph, the first node is a node in the first subgraph, the second node is a node in the second subgraph, the sum of the diameters of the two subgraphs in the target graph pair is smaller than or equal to epsilon · s, wherein epsilon is a preset error value, and s is a graph distance between the first subgraph and the second subgraph.
Wherein the error value epsilon is an error between a desired first shortest path distance, which is an actual shortest path distance between the first node and the second node, and a second shortest path distance, which is a determined (i.e. estimated) shortest path distance between the two nodes.
For convenience of explanation, "the actual shortest path distance between two nodes" may be referred to as "actual shortest path distance". The "shortest path distance between two nodes obtained by estimation" is denoted as "estimated shortest path distance". The error value between the actual shortest path distance and the estimated shortest path distance may be
Figure BDA0001245639470000041
Wherein d is an estimated shortest path distance, which
Figure BDA0001245639470000042
Is the actual shortest path distance.
For example, assuming that the shortest path distance between two nodes needs to be determined, the error value between the desired estimated shortest path distance and the actual shortest path distance is less than or equal to 0.2, and the preset error value ∈ is 0.2. In this case, the shortest path distance d between two nodes determined by the processor according to the method of the embodiment of the present application satisfies
Figure BDA0001245639470000056
It should be understood that a sub-graph in the present application may include one or more nodes. If the subgraph includes a node, the diameter of the subgraph is 0. If the subgraph comprises a plurality of nodes, the diameter of the subgraph is the shortest path distance between two nodes with the longest shortest path distance in the subgraph.
S120, determining the shortest path distance between the first node and the second node as follows: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph.
By adopting the method of the embodiment of the application, the processor can obtain the shortest path distance in the expected error range. This is because:
assuming that the target graph pair corresponding to the first node and the second node (u, v) is (g), (u), g (v)), according to the method of the embodiment of the present application, the shortest path distance d between the two nodes (u, v) is determined(u,v)=s(g(u),g(v))+lg(u)+lg(v)Wherein s is(g(u),g(v))Is the graph distance between the first sub graph g (u) and the second sub graph g (v) in the target graph pair, lg(u)Is the diameter of the first subgraph,/g(v)The diameter of the second sub-figure.
Due to the fact that
Figure BDA0001245639470000051
And lg(u)+lg(v)≤ε·s(g(u),g(v))Can be pushed out
Figure BDA0001245639470000052
Figure BDA0001245639470000053
Figure BDA0001245639470000054
For example, assuming that the processor has a requirement for determining the shortest path distance between a first node and a second node, and the expected error value is 0.2, the processor may determine a target graph pair corresponding to the first node and the second node, and the processor may determine the shortest path distance between the first node and the second node according to the target graph pair by satisfying the following inequality:
Figure BDA0001245639470000055
therefore, according to the method for determining the shortest path distance in the embodiment of the application, the error of the determined shortest path distance is within the control range, and the processor is facilitated to obtain the shortest path distance within the expected error range.
Optionally, in this embodiment of the application, the first node and the second node are nodes in a first graph, and S110 may include: acquiring a plurality of second graph pairs; and determining a target graph pair corresponding to the first node and the second node from the plurality of second graph pairs.
Wherein an ith second graph pair of the plurality of second graph pairs comprises a first subgraph and a second subgraph, all subgraphs of the plurality of second graph pairs belong to the first graph, and the ith second graph pair satisfies a first condition. The ith second map pair is any second map pair of the plurality of second map pairs. Optionally, any two nodes in the first graph correspond to one of the plurality of second graph pairs (i is greater than or equal to 1).
Specifically, the first condition may include a plurality of:
as an alternative example, the first condition may be a sum L of diameters of two subgraphs of the ith second graph pairi≤ε·si. Wherein L isiIs the sum of the diameters of the two subgraphs of the ith second graph pair, siAnd the graph distance of two sub-graphs in the ith second graph pair is shown.
As another alternative, the first condition may be one of a first sub-graph and a second sub-graph of the ith second graph pairInter-picture spacing siThe resolution threshold is more than or equal to.
The split threshold may be determined in a number of ways.
For example, the splitting threshold λi=2(1+ε)·li-max/[ epsilon ], [ wherein, [ l ]i-maxThe diameter of the first subgraph of the ith second graph pair is larger than or equal to that of the second subgraph of the ith second graph pair.
As another example, the split threshold λi=2(1+ε)·li-average/[ epsilon ], [ wherein, [ l ]i-averageThe average value of the diameters of the first graph and the second graph of the ith target graph pair is obtained.
It is to be understood that said ith second graph pair fulfils the first condition, that the sum of the diameters of the first sub-graph and the second sub-graph of the ith second graph pair may be smaller than or equal to si
After the processor obtains the plurality of second graph pairs, a target graph pair may be determined from the plurality of second graph pairs, the target graph pair including a first subgraph and a second subgraph, the first node being a node in the first subgraph, and the second node being a node in the second subgraph.
For example, assume that the first node and the second node are a, B, respectively. The plurality of second graph pairs include (ABCD, EFGH), (ABCD, KECB), (KECB, EFGH), etc. And determining the (ABCD, KECB) as the corresponding target graph pair of the first node A and the second node B.
Further, the processor may obtain the plurality of second graph pairs in at least the following ways.
In a first way,
According to the error value, a plurality of second graph pairs are obtained by splitting the first graph;
in particular, the processor may split the first graph (e.g., the processor may split the first graph using the method 300, which method 300 will be described in detail later) to obtain a plurality of second graph pairs of the first graph. Optionally, any two nodes in the first graph correspond to a single second graph pair of the plurality of second graph pairs. Still taking fig. 1 as an example, the data graph ABCDEFG is split into a plurality of graph pairs including graph pairs (AD, BCE). Assuming a predetermined error value epsilon of 0.2, the sum of the diameters of the two subgraphs of the graph pair (AD, BCE) is 5+12> graph distance 7 · 0.2 of the two subgraphs. Therefore, the graph pair (AD, BCE) is not the second graph pair, and the graph pair (AD, BCE) needs to be continuously split. If the graph pair (A, F) is obtained by splitting, the sum of the diameters of two subgraphs in the graph pair (A, F) is 0+0< 6.0.2, and the graph pair (A, F) belongs to the second graph pair.
Optionally, the method 100 may further include:
and acquiring a minimum spanning tree of the original graph, wherein the minimum spanning tree is the first graph.
Specifically, assuming that the shortest path distance between the first node and the second node in the original graph needs to be determined, the minimum spanning tree of the original graph may be generated, and according to the error value, the minimum spanning tree is split to obtain a plurality of second graph pairs corresponding to the minimum spanning tree (original graph).
The second way,
Acquiring a lookup table of a first graph;
specifically, the lookup table includes a plurality of second map pairs and a plurality of distance values, and the distance value corresponding to the ith second map pair is equal to the sum of the map pitch between two of the ith second map pair, the diameter of the first subgraph of the ith second map pair, and the diameter of the second subgraph of the ith second map pair.
The S120 may include: and determining the shortest path distance between the first node and the second node as a distance value corresponding to the target graph pair.
In particular, the processor may obtain a look-up table of various types of raw graphs.
As an alternative example, the look-up table may comprise the first look-up table. The first lookup table includes a plurality of second map pairs of the first map, and a shortest path distance corresponding to each second map pair (the shortest path distance corresponding to the ith second map pair is a distance value corresponding to the ith second map pair). Wherein, the ith second graph corresponds to the shortest path distance di=si+Li,siIs the graph spacing, L, of the ith second graph pairiThe diameter of the ith second graph pair is the sum of the diameters of two graphs of the ith second graph pair, the ith second graph pair is any one target graph pair of the plurality of second graph pairs, and i is greater than or equal to 1. A portion of the first lookup table may be as shown in table 1.
TABLE 1
Target map pair Shortest path distance
(g(u),g(v)) d(g(u),g(v))
(g(x),g(y)) d(g(x),g(y))
As shown in table 1, the first lookup table includes a plurality of second graph pairs, and each second graph pair corresponds to a shortest path distance. The processor may determine, according to the first lookup table, a target graph pair corresponding to a first node and a second node from the plurality of second graph pairs, where a shortest path distance of the target graph pair corresponding to the first node and the second node is a shortest path distance between the first node and the second node.
It should be noted that table 1 only shows a part of the first lookup table, and table 1 includes a plurality of second map pairs and shortest path distances corresponding to the plurality of second map pairs one to one.
As another example of the optionally, the lookup table may include a second lookup table, where the second lookup table includes a plurality of second graph pairs, a graph pitch of each second graph pair, and a diameter of the first subgraph of each second graph pair, and a diameter of the second subgraph of each second graph pair (where a sum of the diameter of the first graph of the ith second graph pair, and the graph pitch of the ith second graph pair is a distance value corresponding to the ith second graph pair). A portion of this second lookup table may be as shown in table 2.
TABLE 2
Target map pair Distance between drawings Diameter of the first sub-figure Diameter of the second subgraph
(g(u),g(v)) d(g(u),g(v)) lg(u) lg(v)
(g(a),g(b)) d(g(a),g(b)) lg(a) lg(b)
As shown in table 2, the second lookup table includes a plurality of second graph pairs, a graph pitch of each second graph pair, a diameter of the first subgraph of each second graph pair, and a diameter of the second subgraph of each second graph pair. The processor may determine, according to the second lookup table, a target graph pair corresponding to a first node and a second node from the plurality of second graph pairs, where a sum of a graph distance of the target graph pair corresponding to the first node and the second node, a diameter of the first sub-graph, and a diameter of the second sub-graph is a shortest path distance between the first node and the second node.
It should be noted that table 2 only shows a part of the first lookup table, and table 2 includes a plurality of second map pairs and shortest path distances corresponding to the plurality of second map pairs one to one.
It should be further noted that the above listed lookup tables are only examples, and should not be construed as limiting the present application, and any lookup table including the target graph pair of the embodiments of the present application falls within the scope of the present application.
Optionally, in this embodiment of the present application, the lookup table may be generated by the processor. After the processor generates the lookup table of the first graph, if the processor has a need to determine the first node and the second node, the processor may determine the shortest path distance between the first node and the second node according to the lookup table generated by the processor.
Fig. 3 is a schematic flow chart of another example of a method for determining shortest path distance according to an embodiment of the present application. As shown in fig. 3, the method 200 includes:
s210, determining a first target graph pair corresponding to the first node and the second node, and a first vertex and a second vertex corresponding to the first target graph pair.
The first node and the second node are nodes of a first graph. The summary graph of the first graph corresponds to a plurality of second graph pairs, each subgraph in the subgraph set of the first graph corresponds to a plurality of second graph pairs, and the first target graph pair is a graph pair in the plurality of second graph pairs corresponding to the summary graph. The first vertex and the second vertex are vertexes of a graph space corresponding to the first subgraph and the second subgraph in the first target graph pair. Let the first target graph pair be (g), (u), g (v)), and the graph distance between the first sub-graph g (u) and the second sub-graph g (v) of the target graph pair is denoted by a and b, where the vertex a is a node in the first sub-graph g (u) and the vertex b is a node in the second sub-graph g (v).
Still taking fig. 1 as an example, assume that the graph pair includes (ADF, BCEG) the vertices of the shortest path distance corresponding to the sub-graph ADF and the sub-graph BCEG are a point and B point, respectively, and the graph pitch of (ADF, BCEG) is 7.
S220, determining the sum of the graph distance between the first subgraph and the second subgraph, the shortest path distance between the first node and the first vertex and the shortest path distance between the second node and the second vertex of the first target graph pair as the shortest path distance between the first node and the second node.
Specifically, the processor may determine a second target graph pair corresponding to the first node and the first vertex, and determine a shortest path distance between the first node and the first vertex according to the second target graph pair. That is, the processor may determine the shortest path distance between the first node and the first vertex according to method 100. Similarly, the processor may determine the shortest path distance between the second node and the second vertex according to method 100. In other words, the processor may be configured according to the formula: d(u,v)=s(g(u),g(v))+d(u,a)+d(v,b)A shortest path distance between the first node and the second node is determined. Wherein, s(g(u),g(v))The graph distance d between the first sub graph g (u) and the second sub graph g (v) of the first target graph pair(u,a)Is the shortest path distance between the first node and the first vertex, d(v,b)Is the shortest path distance between the second node and the second vertex.
By adopting the method of the embodiment of the application, the processor is beneficial to obtaining the shortest path distance within the expected error range, because:
assuming that the target graph pair corresponding to the first node and the second node (u, v) is (g), (u), g (v)), according to the method of the embodiment of the present application, the shortest path distance d between the two nodes (u, v) is determined(u,v)=s(g(u),g(v))+d(u,a)+d(v,b)Wherein s is(g(u),g(v))The graph distance d between the first sub graph g (u) and the second sub graph g (v) of the first target graph pair(u,a)Is the shortest path distance between the first node and the first vertex, d(v,b)Is the shortest circuit between the second node and the second vertexThe radial distance.
Due to lg(u)+lg(v)≤ε·s(g(u),g(v))And d is(u,a)≤lg(u),d(u,v)≤lg(v)It can be deduced that:
Figure BDA0001245639470000081
Figure BDA0001245639470000082
Figure BDA0001245639470000083
Figure BDA0001245639470000084
for example, assuming that the processor desires to obtain an estimated path distance with an error of 0.2, the processor may obtain the plurality of second map pairs (the plurality of second map pairs including the second map pair of the summary map and the second map pair of the subgraph of the set of subgraphs), the map pitch s of the ith second map pair of the plurality of second map pairsiGreater than or equal to the splitting threshold lambda corresponding to the ith second graph pairiSo that the sum of the diameters of the two maps of the ith second map pair is less than or equal to 0.2 · siThe processor determines a path distance between two nodes from the plurality of second graph pairs that satisfies the following inequality:
Figure BDA0001245639470000085
therefore, the method for determining the path distance in the embodiment of the application is beneficial for the processor to obtain the path distance within the expected error range.
It should be understood that the second diagram pair in the method 200 may refer to the description related to the second diagram pair above, and is not described here again for brevity.
Similar to the above description, the method S210 may include:
acquiring a lookup table;
a first target map pair is determined from the look-up table.
In particular, the look-up table may comprise a third look-up table. The third lookup table includes a plurality of second graph pairs of a summary graph, a graph spacing for each second graph pair of the summary graph, two vertices for each second graph pair of the summary graph, all second graph pairs of the set of sub-graphs, and a shortest path distance for each second graph pair of all second graph pairs of the set of sub-graphs. For example, a portion of the third lookup table may be as shown in Table 3:
TABLE 3
Figure BDA0001245639470000091
In particular, assuming that the first node and the second node are u, v, a first target graph pair (g (u), g (v)) of the plurality of second graph pairs of the summary graph corresponding to u, v may be determined from the third lookup table. The first target graph has vertices a and b, where the first vertex a and the first node u are nodes in the first sub-graph g (u), and the second vertex b and the second node v are nodes in the second sub-graph g (v).
Further, a second target graph pair corresponding to the first vertex a and the first node u, and a third target graph pair corresponding to the second vertex b and the second node v need to be further determined from the corresponding plurality of second graph pairs of the sub-graph set.
Assuming that the first vertex a is a node in g '(x), the first node u is a node in g' (y), and the second target graph pair is determined to be (g '(x), g' (y)), and similarly, a third target graph pair corresponding to the second vertex b and the second node v can be determined.
The processor may determine the shortest path distance between the first node u and the second node v according to the graph distance corresponding to the first target graph pair (g (u), g (v)), the path distance corresponding to the second target graph pair (g '(x), g' (y)), and the path distance corresponding to the third target graph pair (g '(w), g' (z)).
Further, before S210, the method 200 may further include:
selecting partial nodes from the first graph as initial points to construct an initial point set;
generating a summary graph and a sub-graph set according to a graph summary algorithm according to the original graph and the initial point set (alternatively, the summary graph and the sub-graph set can be generated by a Voroni Diagram method, a Delaunay Triangulation method and the like);
splitting the summary graph and the sub-graph set respectively to obtain a plurality of second graph pairs of the summary graph and a second graph pair of each sub-graph in the sub-graph set;
the summary graph may be split according to the method 300 to obtain a plurality of second graph pairs of the summary graph, and each sub-graph in the sub-graph set is split according to the method 300 to obtain a plurality of second graph pairs of each sub-graph (the method 300 will be described in detail later).
In the above, a method for determining shortest path distance is described. In the following, a method 300 for processing graph data is described in detail, which method 300 can be applied in the above-described method to generate a corresponding second graph pair. The method may be performed by a processor. FIG. 4 is a schematic flow chart diagram of a method for processing graph data according to an embodiment of the present application. As shown in fig. 4, the method 300 may include:
s310, initializing, where the first set Q { } is an empty set, and the second set P { } is an empty set; the processor may input a pair of to-be-torn maps (the to-be-torn map may be the first map in the foregoing, may also be a summary map of the first map in the foregoing, and may also be a sub-map in a sub-map set of the first map in the foregoing) into the first set Q { }.
Still taking fig. 1 as an example, the processor may input a pair of to-be-disassembled maps, ABCDEFG, into the first set Q { (ABCDEFG ) }. For convenience of illustration, the graph pair to be disassembled in the first set Q may be referred to as the jth graph pair to be disassembled, where j is greater than or equal to 1.
Alternatively, the minimum spanning tree of the graph ABCDEFG may be input into the first set Q according to a minimum spanning tree algorithm,i.e. Q ═ { R ═ R(ABCDEFG),R(ABCDEFG)R () is a minimum spanning tree method.
S320, determining whether the jth graph pair to be disassembled meets a first condition;
s330, if the jth graph pair to be disassembled meets the first condition, inputting the jth graph pair to be disassembled into a second set P and executing S320 again;
s340, if the jth graph pair to be disassembled does not meet a first condition, splitting a first sub-graph (graph with a large diameter) of the jth graph pair to be disassembled into a third sub-graph and a fourth sub-graph, inputting a graph pair to be disassembled formed by the third sub-graph and a second sub-graph of the jth graph pair to be disassembled into the first set Q, and inputting a graph pair to be disassembled formed by the fourth sub-graph and the second sub-graph of the jth graph pair to be disassembled into the first set Q;
repeating S320-S340 until the first set Q is an empty set, determining a plurality of graph pairs to be disassembled in the second set P as a plurality of second graph pairs of the graph to be disassembled, and outputting a plurality of second graph pairs.
Wherein the first condition may include a plurality of:
for example, Lj≤ε·sjTo satisfy the first condition, Lj>ε·sjThe first condition is not satisfied. Wherein L isjIs the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled, sjIs the graph spacing between two subgraphs of the jth graph pair to be disassembled.
As another example, a split threshold λ may be setj,sjThe first condition is satisfied when the value is larger than or equal to the splitting threshold, and the first condition is not satisfied when the value is smaller than the splitting threshold.
Further, as an optional example, the splitting threshold λ may be determined according to formula (1)j
λj=2(1+ε)·lj-max/ε (1)
Wherein the diameter of the first sub-figure is greater than or equal to the diameter of the second sub-figure,/j-maxThe diameter of the first sub-graph in the jth graph pair to be disassembled is obtained.
As another alternative, the detachment may be determined according to equation (2)Divide threshold lambdaj
λj=2(1+ε)·lj-average/ε (2)
Wherein lj-averageAnd the average value of the diameters of the first sub-graph and the second sub-graph of the jth graph pair to be disassembled is obtained.
It should be noted that the splitting threshold λ of the jth graph pair to be split may be determined according to various waysj. Further, regardless of the manner in which the split threshold is determined, it is eventually necessary to obtain that the sum of the diameters of the two subgraphs is less than or equal to ε · siThe second graph pair of (1).
Optionally, in this embodiment of the application, the first sub-graph of the jth graph pair to be torn may be split into a third sub-graph and a fourth sub-graph according to a diameter of the first sub-graph of the jth graph pair to be torn.
Specifically, the processor may split the first subgraph into a third subgraph and a fourth subgraph uniformly according to the diameter of the first subgraph. Still taking fig. 1 as an example, assuming that the jth graph pair to be disassembled is (ABCDEFG, ABCD), the first sub-graph ABCDEFG can be split, as can be seen from fig. 1, the diameter of the ABCDEFG is 34, so that the ABCDEFG can be uniformly split into (ADF, BCEG) according to the diameter, such that the third sub-graph ADF (diameter 11) and the fourth sub-graph BCEG (diameter 16) are obtained. Two new pairs of to-be-torn maps (ADF, ABCD) and (BCEG, ABCD) may be generated and input into the first set Q.
Optionally, the graph to be disassembled may be a minimum spanning tree. For example, assuming the original graph is split using method 300, the processor may generate a minimum spanning tree for the original graph and split the minimum spanning tree.
The method for determining the shortest path distance according to the embodiment of the present application is described above, and the apparatus and device for determining the shortest path distance according to the embodiment of the present application are described in detail below.
Fig. 5 is a schematic structural diagram of an apparatus for determining a shortest path distance according to an embodiment of the present application. As shown in fig. 5. The apparatus 400 comprises:
a first processing unit 410, configured to determine a target graph pair corresponding to a first node and a second node, where the target graph pair includes a first subgraph and a second subgraph, the first node is a node in the first subgraph, the second node is a node in the second subgraph, and a sum of diameters of the two subgraphs in the target graph pair is less than or equal to s · s, where e is an error value of a preset shortest path distance, and s is a graph distance between the first subgraph and the second subgraph;
a second processing unit 420, configured to determine that a shortest path distance between the first node and the second node is: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph.
The apparatus 400 of the embodiment of the present application determines that the error of the shortest path distance between the first node and the second node is within the control range, so that the apparatus 400 can accurately determine the shortest path distance between the two nodes.
Optionally, the first node and the second node belong to nodes in a first graph; the first processing unit 410 is specifically configured to: obtaining a plurality of second graph pairs of the first graph, wherein the ith second graph pair in the plurality of second graph pairs comprises a first subgraph and a second subgraph, all subgraphs of the plurality of second graph pairs belong to the first graph, and the sum of the diameters of the two subgraphs of the ith second graph pair is less than or equal to epsilon-siWherein s isiThe graph spacing of two subgraphs of the ith second graph pair is the graph spacing of any one of the second graph pairs; and determining a target graph pair corresponding to the first node and the second node from the plurality of second graph pairs.
Optionally, a diameter of a first subgraph of the ith second graph pair is greater than or equal to a diameter of a second subgraph of the ith second graph pair, the ith second graph pair is greater than or equal to a split threshold of the ith second graph pair, where the split threshold λ of the ith second graph pairiComprises the following steps: lambda [ alpha ]i=2(1+ε)·li-maxA,/epsilon; wherein li-maxIs the diameter of the first sub-graph of the ith second graph pair.
Optionally, the first processing unit 410 is specifically configured to: and according to the error value, obtaining a plurality of second graph pairs of the first graph by splitting the first graph.
Optionally, the first processing unit 410 is specifically configured to: inputting two first graphs into a first set as a graph pair to be disassembled; performing the following operations on the graph pairs to be disassembled in the first set: if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is less than or equal to epsilon · sjInputting the jth graph pair to be disassembled into a second set, wherein sjThe graph distance of two sub-graphs in the jth second graph pair is obtained; if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is larger than epsilon · sjSplitting a first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph, inputting a graph pair to be split, which is composed of the third sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, and inputting a graph pair to be split, which is composed of the fourth sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, wherein the diameter of the first sub-graph of the jth graph pair to be split is greater than or equal to the diameter of the second sub-graph of the jth graph pair to be split; determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
Optionally, the first processing unit 410 is specifically configured to: inputting two first graphs into a first set as a graph pair to be disassembled;
performing the following operations on the graph pairs to be disassembled in the first set: if the graph distance of two sub-graphs of the jth graph pair to be disassembled in the first set is greater than or equal to 2(1+ epsilon) · lj-maxInputting the jth graph pair to be disassembled into a second set, wherein lj-maxThe diameter of a first sub-graph of the jth graph pair to be disassembled is larger than or equal to the diameter of a second sub-graph of the jth graph pair to be disassembled; if the graph distance between two sub-graphs of the jth graph pair to be disassembled in the first set is less than 2: (1+ε)·lj-maxSplitting a first subgraph of the jth graph pair to be split into a third subgraph and a fourth subgraph, inputting a graph pair to be split consisting of the third subgraph and a second subgraph of the jth graph pair to be split into the first set, and inputting a graph pair to be split consisting of the fourth subgraph and a second subgraph of the jth graph pair to be split into the first set, wherein the diameter of the first subgraph of the jth graph pair to be split is larger than or equal to that of the second subgraph of the jth graph pair to be split;
determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
Optionally, the first processing unit 410 is specifically configured to: splitting the first subgraph of the jth graph pair to be disassembled into a third subgraph and a fourth subgraph according to the diameter of the first subgraph of the jth graph pair to be disassembled.
Optionally, before the first processing unit 410 obtains a plurality of second graph pairs of the first graph by performing a splitting process on the first graph according to the error value, the first processing unit 410 is further configured to: acquiring an original graph; and generating a minimum spanning tree of the original graph, wherein the first graph is the minimum spanning tree.
Optionally, the first processing unit 410 is specifically configured to: obtaining a lookup table of the first graph, where the lookup table includes a plurality of second graph pairs and a plurality of distance values, and a distance value corresponding to the ith second graph pair is equal to a sum of a graph distance between two of the ith second graph pair, a diameter of a first sub-graph of the ith second graph pair, and a diameter of a second sub-graph of the ith second graph pair; determining, from the lookup table, a target graph pair corresponding to the first node and the second node, where the second processing unit 420 is specifically configured to: and determining the shortest path distance between the first node and the second node as a distance value corresponding to the target graph pair.
The error between the shortest path distance between two nodes determined by the apparatus 400 and the actual shortest path distance between two nodes is within the control range, which is beneficial for the apparatus 400 to accurately determine the shortest path distance between two nodes.
It is to be understood that the apparatus 400 may comprise means and/or modules for performing the methods described above. Moreover, each unit and the other operations and/or functions in the apparatus 400 are respectively for implementing the corresponding flow of the method, and are not described herein again for brevity.
Fig. 6 is a schematic structural diagram of an apparatus for determining a shortest path distance according to an embodiment of the present application. As shown in fig. 6.
The device 500 includes a memory 510 and a processor 520, the memory 510 for storing instructions, the processor 520 for executing the instructions stored by the memory 510. The memory 510 is communicatively coupled to the processor 520.
The processor 520 is configured to: determining a target graph pair corresponding to a first node and a second node, wherein the target graph pair comprises a first subgraph and a second subgraph, the first node is a node in the first subgraph, the second node is a node in the second subgraph, and the sum of the diameters of the two subgraphs in the target graph pair is less than or equal to epsilon · s, wherein epsilon is a preset error value, and s is a graph distance between the first subgraph and the second subgraph; determining a shortest path distance between the first node and the second node as: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph; wherein the error value is an error between a desired first shortest path distance and a second shortest path distance, the first shortest path distance is an actual shortest path distance between the first node and the second node, and the second shortest path distance is a determined shortest path distance between the two nodes.
The error between the shortest path distance between two nodes determined by the apparatus 500 and the actual shortest path distance between two nodes is within the control range, which is advantageous for the apparatus 500 to accurately determine the shortest path distance between two nodes.
It is to be understood that the apparatus 500 may comprise physical units for performing the above-described methods. Moreover, each entity unit and the other operations and/or functions in the apparatus 500 are respectively corresponding to the processes of the method, and are not described herein again for brevity.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (18)

1. A method for determining shortest path distance in graph data processing, the method comprising:
determining a target graph pair corresponding to a first node and a second node, wherein the target graph pair comprises a first sub-graph and a second sub-graph, the first node is a node in the first sub-graph, the second node is a node in the second sub-graph, and the sum of the diameters of the two sub-graphs in the target graph pair is less than or equal to epsilon ∙ s, wherein epsilon is an error value of a preset shortest path distance, s is a graph distance between the first sub-graph and the second sub-graph, and the node represents a position;
determining a shortest path distance between the first node and the second node as: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph.
2. The method of claim 1, wherein the first node and the second node belong to nodes in a first graph;
the determining of the target graph pair corresponding to the first node and the second node includes:
obtaining a plurality of second graph pairs of the first graph, wherein the ith second graph pair in the plurality of second graph pairs comprises a first subgraph and a second subgraph, all subgraphs of the plurality of second graph pairs belong to the first graph, and the sum of the diameters of the two subgraphs of the ith second graph pair is less than or equal to epsilon ∙ siWherein s isiThe graph spacing of two subgraphs of the ith second graph pair is defined as any one second graph pair in the plurality of second graph pairs, and i is greater than or equal to 1;
and determining a target graph pair corresponding to the first node and the second node from the plurality of second graph pairs.
3. The method of claim 2, wherein a diameter of a first subgraph of the ith second graph pair is greater than or equal to a diameter of a second subgraph of the ith second graph pair, and wherein the ith second graph pair is greater than or equal to a split threshold of the ith second graph pair, and wherein the split threshold λ of the ith second graph pairiComprises the following steps:
λi= 2(1+ε)∙ li-max/ε;
wherein li-maxIs the diameter of the first sub-graph of the ith second graph pair.
4. The method of claim 2 or 3, wherein said obtaining a plurality of second graph pairs of the first graph comprises:
and according to the error value, obtaining a plurality of second graph pairs of the first graph by splitting the first graph.
5. The method according to claim 4, wherein obtaining a plurality of second graph pairs of the first graph by splitting the first graph according to the error value comprises:
inputting two first graphs into a first set as a graph pair to be disassembled;
performing the following operations on the graph pairs to be disassembled in the first set:
if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is less than or equal to epsilon ∙ sjInputting the jth graph pair to be disassembled into a second set, wherein sjThe graph distance of two sub-graphs in the jth second graph pair is obtained;
if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is larger than epsilon ∙ sjSplitting a first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph, inputting a graph pair to be split, which is composed of the third sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, and inputting a graph pair to be split, which is composed of the fourth sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, wherein the diameter of the first sub-graph of the jth graph pair to be split is greater than or equal to the diameter of the second sub-graph of the jth graph pair to be split;
determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
6. The method according to claim 4, wherein obtaining a plurality of second graph pairs of the first graph by splitting the first graph according to the error value comprises:
inputting two first graphs into a first set as a graph pair to be disassembled;
performing the following operations on the graph pairs to be disassembled in the first set:
if the graph distance of two sub-graphs of the jth graph pair to be disassembled in the first set is greater than or equal to 2(1+ epsilon) ∙ lj-maxInputting the jth graph pair to be disassembled into a second set, wherein lj-maxThe diameter of the first sub-graph of the jth graph pair to be disassembled;
if the graph distance between two sub-graphs of the jth graph pair to be disassembled in the first set is less than 2(1+ epsilon) ∙ lj-maxSplitting a first subgraph of the jth graph pair to be split into a third subgraph and a fourth subgraph, inputting a graph pair to be split formed by the third subgraph and a second subgraph of the jth graph pair to be split into the first set, and inputting a graph pair to be split formed by the fourth subgraph and a second subgraph of the jth graph pair to be split into the first set;
determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein the diameter of a first sub-graph of the jth graph pair to be disassembled is larger than or equal to that of a second sub-graph of the jth graph pair to be disassembled, and j is larger than or equal to 1.
7. The method according to claim 5 or 6, wherein the splitting the first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph comprises:
splitting the first subgraph of the jth graph pair to be disassembled into a third subgraph and a fourth subgraph according to the diameter of the first subgraph of the jth graph pair to be disassembled.
8. The method according to claim 4, wherein before the obtaining of the plurality of second graph pairs of the first graph by splitting the first graph according to the error value, the method further comprises:
acquiring an original graph;
and generating a minimum spanning tree of the original graph, wherein the first graph is the minimum spanning tree.
9. The method of claim 2 or 3, wherein said obtaining a plurality of second graph pairs of the first graph comprises:
obtaining a lookup table of the first graph, where the lookup table includes a plurality of second graph pairs and a plurality of distance values, and a distance value corresponding to the ith second graph pair is equal to a sum of a graph distance between two of the ith second graph pair, a diameter of a first sub-graph of the ith second graph pair, and a diameter of a second sub-graph of the ith second graph pair;
the determining, from the plurality of second graph pairs, a target graph pair corresponding to the first node and the second node includes:
determining a target graph pair corresponding to the first node and the second node from the lookup table;
the determining a shortest path distance between the first node and the second node is: the sum of the graph spacing s between the first sub-graph and the second sub-graph, the diameter of the first sub-graph, and the diameter of the second sub-graph, comprises:
and determining the shortest path distance between the first node and the second node as a distance value corresponding to the target graph pair.
10. An apparatus for determining shortest path distance in graph data processing, the apparatus comprising:
a first processing unit, configured to determine a target graph pair corresponding to a first node and a second node, where the target graph pair includes a first sub-graph and a second sub-graph, the first node is a node in the first sub-graph, the second node is a node in the second sub-graph, and a sum of diameters of the two sub-graphs in the target graph pair is less than or equal to epsilon ∙ s, where epsilon is an error value of a preset shortest path distance, s is a graph distance between the first sub-graph and the second sub-graph, and the node represents a location;
a second processing unit, configured to determine that a shortest path distance between the first node and the second node is: a sum of a graph spacing s between the first sub-graph and the second sub-graph, a diameter of the first sub-graph, and a diameter of the second sub-graph.
11. The apparatus of claim 10, wherein the first node and the second node belong to nodes in a first graph;
the first processing unit is specifically configured to:
obtaining a plurality of second graph pairs of the first graph, wherein the ith second graph pair in the plurality of second graph pairs comprises a first subgraph and a second subgraph, all subgraphs of the plurality of second graph pairs belong to the first graph, and the sum of the diameters of the two subgraphs of the ith second graph pair is less than or equal to epsilon ∙ siWherein s isiThe graph spacing of two subgraphs of the ith second graph pair is defined as any one second graph pair in the plurality of second graph pairs, and i is greater than or equal to 1;
and determining a target graph pair corresponding to the first node and the second node from the plurality of second graph pairs.
12. The apparatus of claim 11, wherein a diameter of a first subgraph of the ith second graph pair is greater than or equal to a diameter of a second subgraph of the ith second graph pair, and wherein the ith second graph pair is greater than or equal to a split threshold of the ith second graph pair, and wherein the split threshold λ of the ith second graph pairiComprises the following steps:
λi= 2(1+ε)∙ li-max/ε;
wherein li-maxIs the diameter of the first sub-graph of the ith second graph pair.
13. The apparatus according to claim 11 or 12, wherein the first processing unit is specifically configured to: and according to the error value, obtaining a plurality of second graph pairs of the first graph by splitting the first graph.
14. The apparatus according to claim 13, wherein the first processing unit is specifically configured to:
inputting two first graphs into a first set as a graph pair to be disassembled;
performing the following operations on the graph pairs to be disassembled in the first set:
if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is less than or equal to epsilon ∙ sjInputting the jth graph pair to be disassembled into a second set, wherein sjThe graph distance of two sub-graphs in the jth second graph pair is obtained;
if the sum of the diameters of two sub-graphs of the jth graph pair to be disassembled in the first set is larger than epsilon ∙ sjSplitting a first sub-graph of the jth graph pair to be split into a third sub-graph and a fourth sub-graph, inputting a graph pair to be split, which is composed of the third sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, and inputting a graph pair to be split, which is composed of the fourth sub-graph and a second sub-graph of the jth graph pair to be split, into the first set, wherein the diameter of the first sub-graph of the jth graph pair to be split is greater than or equal to the diameter of the second sub-graph of the jth graph pair to be split;
determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein j is greater than or equal to 1.
15. The apparatus according to claim 13, wherein the first processing unit is specifically configured to:
inputting two first graphs into a first set as a graph pair to be disassembled;
performing the following operations on the graph pairs to be disassembled in the first set:
if the graph distance of two sub-graphs of the jth graph pair to be disassembled in the first set is greater than or equal to 2(1+ epsilon) ∙ lj-maxInputting the jth graph pair to be disassembled into a second set, wherein lj-maxThe diameter of the first sub-graph of the jth graph pair to be disassembled;
if it is as describedThe graph distance between two sub-graphs of the jth graph pair to be disassembled in the first set is less than 2(1+ epsilon) ∙ lj-maxSplitting a first subgraph of the jth graph pair to be split into a third subgraph and a fourth subgraph, inputting a graph pair to be split formed by the third subgraph and a second subgraph of the jth graph pair to be split into the first set, and inputting a graph pair to be split formed by the fourth subgraph and a second subgraph of the jth graph pair to be split into the first set;
determining a plurality of graph pairs to be disassembled of the second set as the plurality of second graph pairs when the first set is an empty set, wherein the diameter of a first sub-graph of the jth graph pair to be disassembled is larger than or equal to that of a second sub-graph of the jth graph pair to be disassembled, and j is larger than or equal to 1.
16. The apparatus according to claim 14 or 15, wherein the first processing unit is specifically configured to: splitting the first subgraph of the jth graph pair to be disassembled into a third subgraph and a fourth subgraph according to the diameter of the first subgraph of the jth graph pair to be disassembled.
17. The apparatus according to claim 13, wherein before the first processing unit obtains the plurality of second graph pairs of the first graph by performing a splitting process on the first graph according to the error value, the first processing unit is further configured to:
acquiring an original graph;
and generating a minimum spanning tree of the original graph, wherein the first graph is the minimum spanning tree.
18. The apparatus according to claim 11 or 12, wherein the first processing unit is specifically configured to:
obtaining a lookup table of the first graph, where the lookup table includes a plurality of second graph pairs and a plurality of distance values, and a distance value corresponding to the ith second graph pair is equal to a sum of a graph distance between two of the ith second graph pair, a diameter of a first sub-graph of the ith second graph pair, and a diameter of a second sub-graph of the ith second graph pair;
determining a target graph pair corresponding to the first node and the second node from the lookup table;
the second processing unit is specifically configured to: and determining the shortest path distance between the first node and the second node as a distance value corresponding to the target graph pair.
CN201710151247.7A 2017-03-14 2017-03-14 Method and apparatus for determining shortest path distance Active CN108573001B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710151247.7A CN108573001B (en) 2017-03-14 2017-03-14 Method and apparatus for determining shortest path distance

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710151247.7A CN108573001B (en) 2017-03-14 2017-03-14 Method and apparatus for determining shortest path distance

Publications (2)

Publication Number Publication Date
CN108573001A CN108573001A (en) 2018-09-25
CN108573001B true CN108573001B (en) 2021-11-30

Family

ID=63577294

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710151247.7A Active CN108573001B (en) 2017-03-14 2017-03-14 Method and apparatus for determining shortest path distance

Country Status (1)

Country Link
CN (1) CN108573001B (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2590373B1 (en) * 2008-11-19 2014-12-31 Nippon Telegraph And Telephone Corporation Path calculating method, program and calculating apparatus
CN101458716A (en) * 2008-12-31 2009-06-17 北京大学 Shortcut searching method between nodes in chart
US9137101B2 (en) * 2011-11-23 2015-09-15 Avaya Inc. Multi-layer network diagnostic tracing
CN102521364B (en) * 2011-12-15 2014-10-15 北京大学 Method for inquiring shortest path between two points on map

Also Published As

Publication number Publication date
CN108573001A (en) 2018-09-25

Similar Documents

Publication Publication Date Title
CN109194707B (en) Distributed graph embedding method and device
Lera et al. Deterministic global optimization using space-filling curves and multiple estimates of Lipschitz and Hölder constants
KR101677946B1 (en) Partition expansion method and device
Guerreiro et al. A Fast Dimension-Sweep Algorithm for the Hypervolume Indicator in Four Dimensions.
Friedrich et al. Diameter and broadcast time of random geometric graphs in arbitrary dimensions
CN110084894B (en) Local amplification display method and device of three-dimensional model and electronic equipment
CN101127049A (en) Clustering for structured data
GB2576453A (en) A Method To Estimate The Deletability Of The Data Objects
CN111145328B (en) Three-dimensional character surface texture coordinate calculation method, medium, equipment and device
Perazzo et al. Adaptive methodology for meshless finite point method
CN109344294B (en) Feature generation method and device, electronic equipment and computer-readable storage medium
JP2011033987A (en) Map creating device and map creating method
CN113065036B (en) Method and device for measuring performance of space supporting point and related components
CN108573001B (en) Method and apparatus for determining shortest path distance
Lakizadeh et al. PCD-GED: Protein complex detection considering PPI dynamics based on time series gene expression data
JP2009087235A (en) Model construction device, and method and program for model construction
CN111242670B (en) Method and device for determining seed set of maximum influence degree index
CN108989105B (en) Propagation path diagram generation method and device and server
JP5356711B2 (en) Map information correction apparatus, map information correction method, and program
CN112424628A (en) Positioning device
CN109495305B (en) Reliability evaluation method and device for multi-distribution multi-commodity multi-state flow network
JPWO2017043503A1 (en) Structure estimation device, structure estimation method, and program
CN109388428B (en) Layer traversal method, control device and data processing system
Rouigueb et al. Integration of polynomials over n-dimensional simplices
Smuts et al. New goodness-of-fit tests for exponentiality based on a conditional moment characterisation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant