This application is based upon and claims the benefit of priority of the prior Japanese Patent Application No. 2019-25655, filed on Feb. 15, 2019, the entire contents of which are incorporated herein by reference.
The embodiments discussed herein relate to a path searching method, a storage medium and a path searching apparatus.
In various fields including social networking service (SNS), customer relation management, network management, bioengineering, and transportation, an increased number of applications are utilizing network-based data. The term “network-based data” refers to so-called networks such as the Internet, a web and a transportation network, human relations and relations between molecules. The network-based data include vertices and an edge coupling the vertices. A human relation is modeled by defining humans as vertices and a relationship between the humans as an edge.
Such network-based data are mathematically called a graph or graph data. The graph data are analyzed to extract important information for business, management, a study or the like. A method that searches the shortest path between two vertices such as breadth-first search, Dijkstra method and bidirectional search has been widely utilized for the graph data analysis.
For example, according to Dijkstra method, a vertex 0 is defined as a starting point, and paths to all vertices adjacent thereto are put into a priority queue (or queue with priority). Next, Dijkstra method takes out the path at the beginning of the priority queue. The path [0,1] taken out here is the shortest path from the vertex 0 to the vertex 1. Next, like the processing performed on the vertex 0, Dijkstra method puts, into a priority queue, paths to all vertices adjacent to the vertex 1 that is the last vertex of the taken path. However, the vertex 0 that has already been followed is excluded. After that, Dijkstra method takes out the path [0,2] at the beginning of the priority queues The path [0,2] taken out here is the shortest path from the vertex 0 to the vertex 2. Dijkstra method executes this processing until the end point is taken out from the priority queue to search the shortest path from the starting point to the end point.
In recent years, k paths (hereinafter, which will also be called “k-shortest paths”) from the shortest path to the kth path among paths between two points are searched as a detour search in a transportation network or a computer network communication. For example, a shortest path between a starting point and an end point is acquired. When the shortest path includes p edges, p graphs excluding the edges are considered. The shortest one of the p shortest paths acquired from the graphs is determined as the second shortest path. A similar method thereto is applied to acquire the third and subsequent shortest paths. Related art is disclosed, for example, Japanese Laid-open Patent Publication No. 2017-098593, Japanese Laid-open Patent Publication No. 2010-286978, Japanese Laid-open Patent Publication No. 2016-194908, and E. Filtz, et al, “On finding the k shortest paths in RDF data”, IESD (Intelligent Exploration of Semantic Data), 2016.
According to an aspect of the embodiments, a path searching method to be executed by a computer, the path search method includes identifying a starting point and an end point from among a plurality of nodes included in graph data; when a predetermined number of shortest paths are searched from among paths jointing the starting point and the end point, by using a limit value for which a value lower than the predetermined number is set, identifying a joint point where a path from the starting point and a path from the end point are jointed from both of the starting point and the end point; limiting a number of paths to be held in association with each of the plurality of nodes including the joint point to a number equal to or lower than the limit value and holding a path having a short distance from among paths reaching each of the nodes; searching the predetermined number of shortest paths from among the paths reaching the joint point by using the paths held in association with the nodes; and outputting the searched predetermined number of shortest paths.
The object and advantages of the invention will be realized and attained by means of the elements and combinations particularly pointed out in the claims.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory and are not restrictive of the invention.
In complex graph data having many vertices, the number of paths from one starting point vertex (node) is enormous. In order to search the k-shortest paths in complex graph data, shortest paths are to be searched with respect to the enormous number of paths passing through each of vertices, resulting in a higher amount of computational complexity and longer search times.
An extension of Dijkstra method for acquiring shortest paths (hereinafter, which will sometimes be called “extended Dijkstra method”) may be considered. For example, the extended Dijkstra method searches a path departing from a starting point and reaching an end point substantially concentrically as in breadth-first search. However, not only the shortest path but also the searched second and subsequent shortest paths are held at vertices of the paths passing therethrough during the search. In this way, the extended Dijkstra method executes a search for the k-shortest paths. However, in the extended Dijkstra method, as the number of vertices increases, the number of paths to be searched at each of the vertices enormously increases, which requires the time for the searching processing. In view of this, it is desirable to reduce the time for searching the shortest path.
Embodiments of a path searching method, a path searching program, a path searching apparatus and data structures of path searches disclosed in the present application will be described in detail below with reference to drawings. The embodiments do not limit the present disclosure. The embodiments may be combined with each other as appropriate when there is no contradiction.
Next, the searching apparatus 10 obtains the number of searches desired by a user among paths coupling the starting point and the end point and uses a value lower than the obtained number of searches and a value relating to the number of intermediate points set for the obtained graph data to determine the number of paths from both of the starting point and the end point to a point where the searches meet in nodes of the graph data. After that, the searching apparatus 10 searches paths coupling the determined starting point and end point based on the determined number of paths and outputs the searched paths.
For example, for a higher processing speed, the searching apparatus 10 limits the number of shortest paths held at intermediate points including joint points to be equal to or lower than k by using a method acquired by arranging the extended Dijkstra method that extends Dijkstra method to shortest path search so as to further perform bidirectional search. In the example in
The communication unit 11 is a processing unit that controls communication with another device and is a communication interface, for example. For example, from a terminal of a manager, the communication unit 11 receives graph data and receives an instruction to search k-shortest paths. The communication unit 11 transmits a search result to a designated terminal and transmits a screen displaying the search result to the designated terminal.
The storage unit 12 is an example of a storage device that stores programs and data, and is, for example, a memory, a hard disk, or the like, The storage unit 12 stores a graph data DB 13.
The graph data DB13 is a database that stores graph data to be searched.
More specifically, a weight “1.0” is set for an edge between a vertex 0 and a vertex 1, an edge between the vertex 1 and a vertex 2, an edge between the vertex 2 and a vertex 5, an edge between a vertex 3 and a vertex 4, an edge between the vertex 4 and the vertex 5, an edge between the vertex 5 and a vertex 8, an edge between a vertex 6 and a vertex 7, and an edge between the vertex 7 and the vertex 8. A weight “2.0” is set for an edge between the vertex 0 and the vertex 3, an edge between the vertex 3 and the vertex 6, an edge between the vertex 1 and the vertex 4, and an edge between the vertex 4 and the vertex 7. Hereinafter, in graph data, edges with a weight of “1.0” are indicated by broken lines, and edges with a weight of “2.0” are indicated by solid lines.
The control unit 20 is a processing unit that manages the entire searching apparatus 10 and is, for example, a processor or the like. The control unit 20 has an initial setting unit 21, a searching unit 22, and an output control unit 23. Each of the initial setting unit 21, the searching unit 22 and the output control unit 23 is an example of an electronic circuit included in the processor, an example of a process executed by the processor, or the like.
The initial setting unit 21 is a processing unit that receives settings from a user such as a manager and defines the settings, For example, the initial setting unit 21 defines a starting point and an end point of k-shortest paths, the number of searches (value of k) and the like.
The searching unit 22 has a vertex processing unit 22a, a joint point processing unit 22b, and a path generating unit 22c. The searching unit 22 is a processing unit that stores and holds a result of searching processing in progress in a data structure such as a priority queue and executes searches for k-shortest paths by using the values defined by the initial setting unit 21 on graph data stored in the graph data DB 13.
The vertex processing unit 22a is a processing unit that determines candidates for the shortest paths from both of the starting point and the end point to the vertices. More specifically, the vertex processing unit 22a executes bidirectional search and holds a designated number (k) of paths in increasing order of length among a plurality of paths to vertices. For example, when “2” is set as k, the number of path to be held is set as “1”. Hereinafter, a path from a vertex A to a vertex B with a length of L therebetween is expressed as L[vertex B, vertex A]. When another vertex exists between the vertex A and the vertex B, it is placed in order. For example, when a vertex C and a vertex D exist in order between the vertex A and the vertex B, it is expressed as L[vertex B, vertex D, vertex C, vertex A].
The example in
With respect to the vertex 5 adjacent to the vertex 8 that is the end point, the vertex processing unit 22a identifies 1.0[5, 8] as a path from the vertex 8 to the vertex 5. Because the number of paths to be held to the vertex 5 is 0 that is equal to or lower than the threshold value (1), the vertex processing unit 22a holds 1.0[5, 8] as a path to the vertex 5. Also, with respect to the vertex 7 adjacent to the vertex 8 that is the end point, the vertex processing unit 22a holds 1.0[7, 8] as a path from the vertex 8 to the vertex 7.
Next, with respect to the vertex 2 adjacent to the vertex 1 that has been searched, the vertex processing unit 22a identifies 2.0[2, 1, 0] as a path from the vertex 0 to the vertex 2. Because the number of paths to be held to the vertex 2 is equal to or lower than the threshold value (1), the vertex processing unit 22a holds 2.0[2, 1, 0] as a path to the vertex 2. Also, with respect to the vertex 4 adjacent to the vertex 1 that has been searched, the vertex processing unit 22a identifies 3.0[4, 1, 0] as a path from the vertex 0 to the vertex 4. Because the number of paths to be held to the vertex 4 is equal to or lower than the threshold value (1), the vertex processing unit 22a holds 3.0[4, 1, 0] as a path to the vertex 4.
With respect to the vertex 4 adjacent to the vertex 3 that has been searched, the vertex processing unit 22a identifies 3.0[4, 3, 0] as a path from the vertex 0 to the vertex 4. However, if the path is held, the number of held paths to the vertex 3 exceeds the threshold value (1). Furthermore, the length of the path “3.0[4, 1., 0] to the vertex 4 that has been already held is equal to the current holding target “3.0 [4, 3, 0]. Therefore, the vertex processing unit 22a abandons the current holding target “3.0[4, 3, 0]”. Also, with respect to the vertex 6 adjacent to the vertex 3 that has been searched, the vertex processing unit 22a identifies 4.0[6, 3, 0] as a path from the vertex 0 to the vertex 6. Because the number of paths to be held to the vertex 6 is equal to or lower than the threshold value (1), the vertex processing unit 22a holds 4.0[6, 3, 0] as a path to the vertex 6.
In this way, the vertex processing unit 22a limits the number of paths to be held to each of vertices in path search to the vertices by using a data structure such as a priority queue so that the workload may be reduced. The vertex processing unit 22a executes this processing in both directions from a starting point and an end point and executes the processing until all vertices or the desired shortest paths are searched.
The joint point processing unit 22b is a processing unit that identifies a joint point where a search from a starting point side and a search from an end point side are jointed by using paths to the vertices searched by the vertex processing unit 22a. More specifically, for example, the joint point processing unit 22b identifies, as a joint point, a vertex with a path that has been searched from an end point side if the vertex is with a path from a starting point side that has already been searched. The joint point processing unit 22b notifies the path generating unit 22c of information regarding the joint point.
For example, when a path “20[2, 5, 8]” from the end point to the vertex 2 is searched and held by the vertex processing unit 22a, the joint point processing unit 22b identifies the vertex 2 as a joint point if the path “2.0[2, 1, 0] to the vertex 2 searched from the starting point has already been searched. On the other hand, when the path “2,0[2, 5, 8]” from the end point to the vertex 2 is searched and held by the vertex processing unit 22a, the joint point processing unit 22b does not identify the vertex 2 as a joint point if the path to the vertex 2 searched from the starting point has not been searched,
The path generating unit 22c is a processing unit that generates k-shortest paths by using the search result by the vertex processing unit 22a and the identification result by the joint point processing unit 22b. When a joint point is identified, the path generating unit 22c generates a path by combining the path from the starting point to the joint point and the path from the end point to the joint point. The path generating unit 22c holds k generated paths at a maximum. Upon determination on whether the generated path is to be held or not, the path generating unit 22c complies with the limitation of the maximum k paths by deleting paths having a large weight (long path length).
Describing with reference to the example above, when the vertex 2 is identified as a joint point, the path generating unit 22c combines the path “2,0[2, 1, 0]” from the starting point to the joint point (vertex 2) and the path “2.0[2, 5, 8]” from the end point to the joint point (vertex 2) to generate a path “4.0[0, 1, 2, 5, 8] from the starting point to the end point. If the number of the currently held paths is lower than 2 (k=2), the path generating unit 22c holds the path “4.0[0, 1, 2, 5, 8]” as it is.
If the number of the currently held paths is equal to 2 (k=2) and there are other paths having a path length longer than 4.0, the path generating unit 22c deletes the longest path of the other paths and holds the path “4.0[0, 1, 2, 5, 8]”. if the number of the currently held paths is equal to 2 (k=2) and no other paths having a path length equal to or longer than 4.0 are held, the path generating unit 22c abandons the path “4.0[0, 1, 2, 5, 8]”. In this way, the path generating unit 22c holds the k-shortest paths by complying with the limitation of the number of paths to be held that is equal to or lower than k every time a joint point is identified.
The output control unit 23 is a processing unit that outputs the k-shortest paths generated by the searching unit 22. More specifically, for example, the output control unit 23 stores, in the storage unit 12 or the like, k paths generated and held by the path generating unit 22c when the execution of the processing on the vertices is completed by the searching unit 22. As a result of the k-shortest path search, the output control unit 23 transmits k paths to a terminal of a manager or outputs k paths to a display unit such as a display device.
A more specific example of the k-shortest path search will be described below.
In a case where certain two people are suspected to be related to fraud, the shortest path between the two people may be searched so that through which path the two people get acquainted with each other or other people or companies that relate to the fraud may be easily investigated. However, highly possibly, they are related through a path excluding the shortest path. In this case, a plurality of paths may be searched by k-shortest path search, and a k-shortest path result that is the search result may be displayed on a screen for highly precise investigation.
In the example in
Next, an example will be described in which the aforementioned processing is specifically executed by using priority queues.
As illustrated in
Next, if Q[0] or Q[1] is not empty (S102, Yes), the searching unit 22 substitutes 0 for i (S103) and determines whether the current i is equal to or lower than 1 (S104).
If i is equal to or lower than 1 (S104: Yes) and Q[i] is not empty (S105: Yes), the searching unit 22 takes out from Q[1] a path pth_v from the starting point to a vertex v (S106). For example, the searching unit 22 holds the path path_v in P[i][v.id( )]. v.id( )is a number of the vertex v.
The searching unit 22 determines whether the number of held paths is lower than p_max or not (S107). If the number of held paths is lower than p_max (S107: Yes), the searching unit 22 executes processing of jointing paths path_v (S109). For example, if the point v is a joint point, the searching unit 22 joints path_v and a path P[opp(i)][v.id( )] and puts the result into totalQ. opp(i) is a function that returns the number of the opposite side of i, that is, the function returns 1 if i=0 and returns 0 if i=1.
After that, the searching unit 22 executes the joint processing on the vertex v (S110), increments i (S111) and executes the processing in S104. For example, the searching unit 22 generates a path path_w=[w, path_v] for a vertex w adjacent to the vertex v and put it into Q[i].
If the number of held paths is equal to or higher than p_max in S107 (S107: No), the searching unit 22 executes processing in S111 and subsequent steps, If Q[i] is empty in S105 (S105: No), the searching unit 22 executes the processing in S111 and subsequent steps.
If i is higher than 1 in S104 (S104: No), the searching unit 22 executes the processing in S102 and subsequent steps. If Q[0] and Q[1] are empty in S102 (S102: No), the searching unit 22 outputs the searched paths as a result (S112).
In a case where the shortest paths the number of which is desired by a user are to be searched by bidirectional search based on extended Dijkstra method, the searching apparatus 10 limits information on paths held during searches, as described above. Thus, even when there are an enormous number of vertices, the searching apparatus 10 may search paths desired by a user with high precision, and, at the same time, the amount of computational complexity may be reduced.
Next, detail algorithms of the searching processing to be executed by the searching apparatus 10 according to Embodiment 1 as described above will be described. Terms used in this embodiment will be described first, and then the algorithms will be described.
In a graph, a point is called a vertex, and a line is called an edge. A set of vertices in a graph is indicated by V, and a set of edges is indicated by E. When the graph is G, G=(V, E). This means that the graph G is a graph including a set V of vertices and a set E of edges.
A graph having an edge that has no direction is called an undirected graph, and a graph having an edge that has a direction is called a directed graph. For example, when all of roads are bidirectional, the road system may be expressed by an undirected graph. However, if a one-way road is included, the road system is expressed by a directed graph.
A graph having weighted edges is called a “weighted graph”, and a graph having unweighted edges is called an “unweighted graph”. For example, a railway network may be expressed as a weighted graph by defining vertices as stations and giving a distance or required time between stations to an edge between the corresponding vertices. On the other hand, when a human relationship is considered only by focusing on its friendship and intimacy of the relationship is not considered, the friendship may be expressed as an unweighted graph.
When two vertices are coupled by one edge, it is said that the two vertices are adjacent, A list of vertices adjacent to one vertex v is called an adjacent vertex list of the vertex v. If the graph is a weighted graph. a pair of an adjacent vertex and a length of the edge to the vertex is held as a list.
Regarding a “path”, when vi−1, vi are adjacent for an arbitrary i (1≤i≤n) in a vertex string [v0, v1, . . . , vn], the vertex string is called a path. In a directed graph, an edge from vi−1 to vi is required to be included in E. v0 is called a “starting point” of a path, and vn is called an “end point”. This embodiment assumes that a vertex does not appear repeatedly on a path.
Regarding “length of a path”, each edge is considered to have a weight of 1, and a total of weights of edges on a path is called a “length of the path” or “path length”. Normally, a path between two vertices having the shortest length is called a “shortest path”. There is a possibility that a plurality of shortest paths exists normally. In this embodiment, not only the shortest path in a general sense but paths which may be called a predetermined number of semi-shortest paths in increasing order are also simply called “shortest paths”.
The k shortest paths including from the shortest path to the kth shortest path between one vertex vs to another vertex vt are called “k-shortest paths” where 1≤k and the processing for acquiring the k-shortest paths is called “k-shortest path search”. vs and vt are called a starting point and an end point, respectively. Bidirectional search includes searches from both of the starting point and the end point, as will be described below. In this sense, both of them may also be called a “departing point”. A path having a starting point and an end point that are matched is called a closed path. A point traced during a search between a starting point and an end point in k-shortest path search is called an “intermediate point”. A point that is a type of intermediate point where a path from a starting point and a path from an end point meet is called a “joint point”.
In order to acquire a shortest path, a process of “tracing” edges from a vertex is performed. How early this process is stopped is important for increasing the speed of the processing. In this embodiment, the speed of the search processing is increased by “reduction by approximation method” and “reduction by max (reduction of unnecessary tracing by using the length of the kth shortest path acquired as a candidate for a solution)”.
For example, for acquiring k-shortest paths, an approximation of the solution may be enough instead of an accurate solution. In a case of data analysis for acquiring a bypass of a traffic route or a communication channel or a human relationship, processing that provides a solution sufficiently close to an optimum solution at a higher speed may be desirable even at little sacrifice of accuracy. Ina case of a traffic route, a method that acquires a solution in three seconds even with slightly lower precision is more preferred than a method that provides an accurate solution in one minute. In the present age of big-data, data analysis is required. In this case, calculation of the shortest path or shortest paths up to the kth shortest path is required in many pairs of two vertices. It is predictable that the processing takes an enormous amount of time with large scale data. In this case, it may be considered that the speed often has higher priority than precision.
The “reduction by approximation method” involves parameter adjustment. Therefore, the parameter optimization is automated. Graphs include undirected/directed graphs and weighted/unweighted graphs, Four (2×2) types of graphs are considered by combining them. This embodiment is applicable to all of the types. This embodiment assumes a weighted and undirected graph.
One of differences between this embodiment and a general method is a limitation to k or lower of the number of paths from a starting point or an end point at an intermediate point including a joint point. The precision defined as being acceptable by a user is Pmin. This setting may be changed arbitrarily by a user.
According to this embodiment, the number of partial shortest paths to be acquired from a departing point to an intermediate point is limited to k or lower. The reduction of the searching processing increases the speed. The limited number of partial shortest paths is called a “maximum number of paths” and is indicated by pmax hereinafter. Random reduction of pmax increases the speed. However, the precision may possibly decrease. Accordingly, in view of the precision and the speed, pmax is limited to the extent expressed by Expression (1) where α is a parameter. With the limitation, ks (≤pmax) partial shortest paths from a starting point and kt (≤pmax) partial shortest paths from an end point are acquired at a joint point. The shortest paths from the starting point and the end point are combined so that ks×kt shortest path candidates from the starting point to the end point may be acquired. The shortest paths up to the kth shortest path in increasing order are acquired from the shortest path candidates acquired at joint points to acquire a final result.
pmax=α√{square root over (k)} (1)
A reason why Expression (1) is valid will be described. By assuming that Expression (1) is satisfied and assuming that the starting point side and end point side partial shortest paths the number of which is indicated by the right side of Expression (1) are acquired at joint points, the partial shortest paths are combined at the joint points. Then, the shortest path candidates the number of which is indicated by Expression (2) are acquired.
(α√{square root over (k)})2=α2k (2)
There are many joint points normally. When the number of joint points is c, “c×Expression (2)” shortest paths are totally acquired. The value is at least required to be higher than k. However, the acquired shortest paths may include redundant paths, and if a lower number of shortest paths are acquired, it does not satisfy the user's requirement of precision Pmin or higher. Therefore, some times of k is required to acquire. When the number is β, cα2k=βk as in expressed in Expression (3).
Conversely, by setting the value as the value of α, the result may satisfy the user's satisfaction of precision. While β and c are handled as fixed numbers, these values may be influenced by k and positions of the starting point and the end point. Because of this, α may also vary. Performing statistic processing may be considered which changes k in a range to be used by a user and changes the starting point and the end point and acquires a maximum value or a mean value of α in the changed conditions. When the requirement for precision is strict, the maximum value may be acquired. If it is not so strict, the mean value may be acquired. Values of k may be divided into several ranges, and α may be determined for each of the ranges. Optimization of the parameter α will be described below.
Reduction by max assumes that a candidate for the kth shortest path (the kth shortest one among the acquired shortest paths though whether it is truly the kth shortest path or not is unknown) has been acquired. It is assumed that the length is max. According to this method, a path traced from a departing point to the vertex v and its length are managed in a priority queue and is to be put into and taken out from the priority queue.
As illustrated in
The broken lines in
Regarding (1), cases illustrated in
In both cases, if an inequality “max≤lsv+min” (this inequality will simply be called “criterion with max”) is satisfied, a shortest path that is shorter than max may not be acquired even by further extending the search from the vertex v. In other words, this means that the search may be stopped without requiring the extension from the vertex v. The reason will be described below.
For example, it is assumed that a shortest path shorter than max is acquired by combining the path with the shortest path from the other side at the vertex y reached by further tracing the path from the vertex v. In this case, as illustrated in
In the case in
Hereinafter, this is satisfied in a case where the vertex taken out from the queue Qs is v. Because the queue is a priority queue, the length of the path to the vertex v taken out after this is equal to or longer than the length of the path to the currently taken vertex v. Because of this, hereinafter, in a case where the leading end of the path taken out from the queue Qs is the vertex v, no further extension is required irrespective of the length of the path. It is noted here that no extension is required at the vertex v from the vertex s side but it may not be said that no extension at the vertex v from the vertex o side is required.
(2) where further extension from the vertex v may be performed will be examined. In this case, the vertex w adjacent to the vertex v is investigated. Whether further search from the vertex w is to be performed or not, that is, whether the path to the vertex w is to be put into the queue Qs is problem. Also in this case, for the exactly same reason as that for the vertex v, if max≤lsw+min is satisfied, no extension further from the vertex w is required. Therefore, the path is not required to be put into the queue Qs. lsw is calculated by lsw=lsv+lvw where lvw is a length of the edge between the vertices v and w,
However, unlike the case of the vertex v, in a case where the leading end of the path taken out from the queue Qs from now on is the vertex w, it may not be said that no further extension is required irrespective of the length of the path to the vertex w. This is because there is a possibility that the vertex w is not the leading end of the path taken out from the queue Qs and a shorter path than lsw is taken out from the queue Qs from now on. In other words, for example, it may be said that the path to w acquired by adding w to the path having lsw from s to v may not be put into the queue.
Therefore, the extension from the departing point side may be stopped at the vertex v in (1) and the path to the vertex w via the vertex v may not be put into the queue Qs, in (2), which contribute to the corresponding increase of the processing speed. Actually, the speed is increased about 10 times in Embodiment 4, which will be described below. The deletion of unnecessary tracing based on the criterion with max described above will simply be called “Reduction by max”.
Next, k-shortest path search processing by approximation will be concretely described. A structure of a graph and a structure of a queue will be described first, and a specific flow of the processing will then be described.
As described above, the maximum number pmax of paths is “ceil (Expression (1)”. In this case, “ceil(x)” is a function that rounds up a floating point number x to an integer.
The following three types of priority queues are used in the shortest path search, When the length of a shortest path is “path_length” and a path is “path”, the pair “path_length, path] or only “path_length” is put into a priority queue.
A total queue is represented by “totalQ”. When the length of a shortest path is “path_length” and a path is “path”, the pair [path_length, path] is put into the totalQ” for each of the shortest path to the kth shortest path from a starting point to an end point. The “totalQ” may store a maximum of k data pieces. When more data pieces are to be stored, a path having a highest “path_length” is deleted. The term “maximum value of “totalQ”” refers to a maximum length of lengths of stored paths, which may be referred by “total.max( )”. For example, in a case where a new path is to be stored in “totalQ” already storing k paths, the new path is not stored if the length of the path is equal to or higher than the maximum value. The “totalQ” initially has an empty state, and the number of shortest paths stored in the “totalQ” may be referred by “totalQ.len( )”. len( ) is a function that returns an element of not only totalQ but also a general list and is used in the following other lists. In this embodiment, totalQ.len( ) is applied which means that totalQ is a first argument of the function len( ) and has the same meaning as len(totalQ). Generally, x.f( ) has the same meaning as f(x).
The priority queue for the starting point side is represented by “Q[0]” and the priority queue for the end point side is represented by “Q[1]”. Because this embodiment applies bidirectional search, two queues are prepared. It is assumed that the starting point side is represented by 0 and the end point side is represented by 1 according to this embodiment.
For example, when the path length of a partial shortest path to a certain vertex is “path_length” and the path is “path”, the pair [path_length, path] is stored in a priority queue. While a path is not generally stored according to Dijkstra method, a plurality of paths is required to be memorized in the shortest path search. “Q[0]” initially stores [0.0,[vs]] when the starting point is vs, and “Q[1]” initially stores [0.0,[vt]] when the end point is vt. The “path_length” of the shortest path among paths stored in Q[i] (i=0, 1) or the path stored at the beginning may be referred by “Q[i].min( )”.
Two priority queues “q0” and “q1” are prepared for vertices, and the lengths of the partial shortest paths from the starting point and the end point to the vertex v are stored in “q0” and “q1”. A maximum of pmax shortest path lengths “path_length” are stored in the “q0” and “q1”. In a case where pmax path lengths have already been stored and if “path_length” of a new path length is equal to or higher than the highest value of the stored path lengths, the new path length is not stored.
When a new path length is actually stored, that is, when the number of stored path lengths is lower than pmax or lower than a maximum value, “q0” or “q1” returns “true” and otherwise returns “false”. [q0, q1] is stored in q[v.id( )] in the list q, and q0 and q1 are referred by q[v.id( )][0] and q[v.id( )][1], respectively. In this case, “v.id( )” is a function that returns an identifier of v (one of the numbers from 0 to n−1 given to each vertex where the number of vertices is equal to n).
The length of a path is to be stored in “q0” or “q1” because, if the length is equal to or lower than the pmaxth length, the path is stored in Q[0] or Q[1] and, if the length is higher than the pmaxth length, the path is abandoned based on the policy of this embodiment. In both cases, the path is not required to be stored in“q0” or “q1”. [q] initially stores [0.0] for the values of q[s][0], q[t][1][q] where the vertex identifies of the starting point and the end point are s and t, respectively and stores an empty list [ ] for the other elements.
A list that manages partial shortest paths reaching from the starting point side and the end point side to the vertex v is P, and P[v.id( )][i] represents a list of a plurality of, generally, shortest paths reaching the vertex v on the i (i=0, 1) side. In other words, if i=0, it represents a list of paths reaching from the starting point to the vertex v. If i=1″ it represents a list of paths from the end point. The kth shortest path is represented by P[v.id( )][i][k−1]. Each shortest path is represented by [path_length, path], like the total queue, starting point queue and the end point queue. “path_length” and “path” of the kth shortest path may be referred by “P[v.id( )][i][k−1].path_length” and “P[v.id( )][i][k−1].path”, respectively. An initial state of P is a list [ ] where all elements are empty.
Whether the vertex v is a joint point or not is represented by “is_joint[v.id( )]” in a list “is_joint”. In other words, for example, if the value is true, it means that the vertex v is a joint point. At an initial state of the list “is_joint”, all elements have False.
“is_extended_list[v.id( )][i]” in a list “is_extended_list” indicates whether the search is to be extended from the vertex v. For example, if i=0, it represents that a search reaches from the starting point to the vertex v. If i=1, it represents that a searches reaches from the end point to the vertex v. In other words, for example, if the value is true, the leading end (or search) is to be extended further from the vertex v. At the initial state of “is_extended_list”, all elements have True.
If “i≤1” is satisfied (S14: Yes), the searching unit 22 determines whether “Q[i].len( )=0” is satisfied or not (S15). If it is satisfied (S15: Yes), i is incremented (S16). The processing in S14 and subsequent steps is repeated.
On the other hand, if “Q[i],len( )=0” is not satisfied (S15: No), the searching unit 22 takes out the first data of Q[i], sets the length to path_length_v and the path to path_v and sets the 0th element of path_v to v (S17). Q[i].deque( ) is a function that takes out the first data of the queue, and the value of Q[i].deque( ) is a list [l,p] including a pair of a path length l and a path p. Because the queue stores lengths of paths and paths in increasing order of the path length, the shortest path is taken out. Generally, [a,b]=[c,d] means that c is set to a and d is set to b. After that, the searching unit 22 determines whether the list “is_extended(v,i,path_length,True)” is True or not (S18). If it is “True” (S18: Yes), processing for extending the vertex v is executed (S19). After the extension processing, the processing in S16 and subsequent steps is repeated.
If the list is_extended(v,i,path_length)” is not “True” (S18: No), the searching unit 22 repeats the processing in S16 and subsequent steps. If “i≤1] is not satisfied in S14 (S14: No), the searching unit 22 returns to S11 and repeats processing in subsequent steps. If “0<Q[0].len( ) or 0<Q[1].len( )” is not satisfied in S11 (S11: No), the searching unit 22 substitutes the value returned, by “totalQ.sorted_list( )” for a variable lp_list (S12) and ends the processing.
Describing the aforementioned processing more specifically, the entire processing is continued if the priority queue Q[0] or Q[1] is empty as expressed by the condition “0<Q[0].len( ) or 0<Q[1].len( )”. Then, the last vertex v in the partial shortest path from the departing point is taken out for [path_length_v,path_v] taken out from Q[0] or Q[1] that is not empty based on “v=path_v[0]”.
“len( )” is a function (method) that returns the number of elements stored in a list such as the number of elements stored in a priority queue. “sorted_list( )” is a function that returns a list acquired by sorting a pair [l,p] of a path length I and a path p stored in “totalQ” in increasing order of l, that is, a list of a pair of a length of k shortest paths and the paths to be acquired by this algorithm.
Next, the searching unit 22 adds [path_length,path_v] to P[vid][i] based on “P[v.id( )].append([path_length,path_v])” (S23). The searching unit 22 then determines whether “is_joint[v.id( )]” is “True” or not (S24).
If “is_joint[v.id( )]” is “True” (S24: Yes), the searching unit 22 executes processing in S25. More specifically, the searching unit 22 combines paths in “path_v” and “P[v.id( )][opp(i)]”. The searching unit 22 then stores, in totalQ, a path not including a loop, not being included in totalQ and having a length lower than the maximum value of totalQ among the combined paths.
After that, the searching unit 22 executes adjacent vertex processing on the vertex v (S26). If “is_joint[v.id( )]” is not “True” in S24 (S24: No), the searching unit 22 executes processing in S26 without executing the processing in S25. If “is_joint[v.id( )]=False and 0<P[v.id( )][opp(i)].len( )” is not satisfied in S21 (S21: No), the searching unit 22 executes the processing in S23 without executing the processing in S22.
Describing the aforementioned processing more specifically, the condition “is_joint[v.id( )]=False” represents that the vertex v is not a joint point, and the condition “0<P[v.id( )][opp(i)].len( )” represents the number of partial shortest paths from the departing point on the other side to the vertex v is higher than 0, that is, the path has already reached from the departing point on the other side to the vertex v and the vertex v becomes a joint point at this time. Accordingly, “is joint[v.id( )]=True is defined. opp(i) is a function that returns the opponent of i. In other words, for example, 1 is returned if i=0, and 0 is returned if i=1. [path_length,path_v] is added to P[vid][i] based on “P[v.id( )].append([path_length,path_v])”.
Then whether the vertex v is a joint point or not based on “is_joint_list[v.id( )]=True”. If so, paths of “path_v” and “P[v.id( )][opp(i)]” are combined. In other words, for example, partial shortest paths stored in [path_length,path_v] and P[vid][opp(i)] are combined to form a shortest path from the starting point to the end point. In a case where three conditions that the formed shortest path does not have a loop, is different from the shortest path stored in totalQ and is lower than the maximum value of totalQ are satisfied, the formed shortest path is stored in totalQ.
The path combination will be described more specifically. It is assumed that “P[v.id( )][opp(i)]” stores [[l1,p1], [l2,p2], . . . [lk,pk]]. “li” is a path length, and “pi” is a path. These paths and [path_length_v,path_v] are combined. In other words, for example, [path_len+li,path_v+pi] (i=1, 2, . . . , k) is formed. Finally, in order to extend the path from the vertex v, processing relating to vertices adjacent to the vertex v is performed.
If “w” is not included in “path_v” (S32: Yes), the searching unit 22 substitutes “(path_length_v)+(edge_length)” for “path_length_w” (S33).
Whether “is_extended(w,i,path_length_w,False)” is “True” or not is determined (S34). If it is “True”, the processing in S35 is executed,
If “q[v.id][i].enque(path_length_w)” is “True” (S35: Yes), the searching unit 22 generates a path to “w” based on “path_w=[w,path_v]” and stores “path_length_w,path_w” in Q[i] (S36). After ghat, the processing in S31 and subsequent steps is repeated.
If “q[v.id][i].enque(path_length_w)” is not “True” in S35 (S35: No), if “w” is included in “path_v” in S32 (S32: No) and if “is_extended(w,i,path_length_w,False)” is not “True” in S34 (S34: No), the searching unit 22 repeats the processing in S31 and subsequent steps.
If “v.adj_edge_list( )” does not have an unprocessed [w,edge_length] in S31 (S31: No), the searching unit 22 ends the processing.
Describing the aforementioned processing more specifically, “v.adj_edge_list( )” is a function that returns a list (which will be called “adjacent vertex list) of a pair “w,edge_length” of a vertex w adjacent to the vertex v and the length “edge_length” of the edge between the vertex b and the vertex w. If an unprocessed “w,edge_length” remains, the processing is continuously executed.
Next, whether the vertex w is not included in the path to the vertex v “path_v” is checked. This is because there is a loop if the vertex w already exists in the path.
Next, based on “path_length_w=path_length_v+edge_length”, the length of a shortest path from the departing point to the vertex w is acquired. Then, whether “is_extended(w,i,path_length_w,False)” is “True” or not is determined. If it is “True”, whether path_length_w with the value of q_list[w.id( )][i].enque(path_length_w) may be stored in the priority queue. If it may be stored, it means that path_length_w is within the pmaxth paths that have reached the vertex w. In other words, for example, there is a possibility that the path may be extended further after the vertex w. The expression, “there is a possibility” is used because there is also a possibility that a shortest path shorter than the path reaches the vertex w after this, and the shorter path is not within pmax.
Accordingly, a path to the vertex w is generated based on path_w=[w,path_v], and “path_length_w,path_w” is stored in Q[i] based on Q[i].enque([path_length_w,path_w]). By using path_w=[w,path_v] and the path path_v to the vertex v, path_w may be efficiently defined.
Then, if “is_extended_list[x.id( )][i]” is True (S312 Yes), the searching unit 22 determines whether P[x.id( )][i].len( ) is lower than pmax or not (S313).
If P[x.id( )][i].len( ) is lower than pmax (S313: Yes), the searching unit 22 determines whether the kth shortest path has been acquired and the path length max has been acquired or not (S314).
If the kth shortest path and the path length max have been acquired (S314: Yes), the searching unit 22 determines whether P[x.id( )][opp(i)].len( ) is higher than 0 or not (S315). If P[x.id( )][opp(i)].len( ) is equal to 0 (S315: No) and if Q[opp(i)].len( ) is equal to 0 (S316: No), the searching unit 22 substitutes False for is_extended_list[x.id( )][i] (S317).
If P[x.id( )][opp(i)].len( ) is higher than 0 (S315: Yes), the searching unit 22 substitutes P[x.id( )][opp(i)][0].path.length for “min” (S318). If Q[opp(i)].len( ) is higher than 0 (S316: Yes), the searching unit 22 substitutes Q[opp(i)].min( ) for “min” (S319). The searching unit 22 after executing the processing in S317 defines “r=False” (S322), returns the value r, and ends the processing.
The searching unit 22 after executing the processing in S318 or S319 determines whether “path_length+min” is lower than max or not (S320). If “path_length+min” is lower than max (S320: Yes), the searching unit 22 keeps r=True, returns the value r and ends the processing.
If “path_length+min” is equal to or higher than max (S320: No), the searching unit 22 determines whether is_v is “True” (S321). If so, the searching unit 22 executes the processing S317 and, if not, performs the processing in S322. If the path length of the kth shortest path has not been acquired in S314 (S314: No), the searching unit 22 returns the value r and ends the processing.
The aforementioned processing will be described more specifically,
If “is_extended_list[x.id( )][i]” is False in S312, it means that the path is not required to be extended further from the vertex x, Therefore, “r=False” is defined in S322, and the value r is returned. Then, the processing ends. If P[x.id( )][i].len( ) reaches pmax in S313, the partial shortest path to this vertex is not required to be acquired no more, Therefore, “is_extended_list[x.id( )][i]” is False in S317. As a result, from the next processing time, “r=False” is instantly determined in S312. With this condition, reduction of the searching processing may be realized.
The expression “the kth shortest path has been acquired” in S314 means that k shortest paths have already been stored in the total queue “totalQ” (which is determined by determining whether the value of totalQ,len( ) is equal to k) and the expression “the path length is max” means that the value of totalQ.max( )is max. In this case, reduction by max is possible in S315 and subsequent steps or not is determined to realize high-speed processing,
For min acquired in S318 and S319, the value is set by S318 if the condition in S315 is satisfied and the value is set by S319 if the condition in S315 is not satisfied but the condition in S316 is satisfied, If the criterion with mx in S320 is satisfied, there is possibility that a shortest path from the starting point to the end point that is shorter than max is acquired. Therefore, it is determined that the extension at the vertex x is not stopped, Otherwise, the result depends on whether the vertex x is the vertex v or the vertex w in S321. If the vertex x is the vertex v, the extension processing from the departing point side at the vertex x is set to be stopped in S317. In other words, for example, unnecessary extension processing may be suppressed, leading to an increase of the speed of the processing. If the vertex x is the vertex w, the path extension to the vertex W is not simply performed due to the processing in S322. In other words, for example, it is determined that the path is not put into the queue. Though it may not be said that the extension is not performed in the vertex w, unlike the case of the vertex v, the suppression of storage of the path to the queue contributes to an increase of the speed of the processing.
Next, a specific example of the aforementioned processing will be described with reference to
The drawings are further simplified as follows. The parentheses ([,]) indicating a list are omitted, and a vertex vi is simply indicated by an integer i. A recursive structure of a path is simplified and is written as a flat list. For example, a path that is to be written as [3,[2,[1]]] is simplified to [3,2,1]. is_joint_list is not illustrated in the drawings. P[i] is written in bold type to indicate that is_joint_list[i] is True.
First, searching processing on the starting point side is executed. As illustrated in
Also, the searching unit 22 identifies the length “2.0” from the vertex 0 to the vertex 3. Because the number of paths stored in q[3][0] of the vertex 3 is lower than pmax (=1), “2.0” is stored in q[3][0]. The searching unit 22 stores [2.0,[3,0]] as path information [length, path=[vertex, vertex]] from the starting point to the vertex 3 in the starting point side priority queue Q[0].
Next, searching processing on the end point side is executed. As illustrated in
This processing will be described in more detail. Because Q[0] and Q[1] are not empty, the condition in S11 in
Next, the searching unit 22 in S18 invokes the function is_extended( ) that determines whether the processing of extending v in S19 and subsequent steps is to be performed or not. Because S312 and S313 in
After that. the searching unit 22 determines the condition for determining whether the vertex v is a joint point or not in S21 in
Because [1,1,0] and [3,2.0] are remained as being unprocessed in S31, the searching unit 22 first selects [1,1.0] as [w,edge_length] and executes S32. Next, the searching unit 22 determines the condition in S32 is satisfied. Because w=1 is not included in path_v=[0], the searching unit 22 executes S34. Because path_length_v=0.0 and edge_length=1.0, the path length path_length_w to the vertex w is calculated as “1.0”. After that, though the searching unit 22 stores path_length_w in the list q[0][0] in S35, the lust is still empty. Therefore, the condition in S35 is satisfied, and S36 is executed. path_w=[w,path_v] is defined, and [path_length_w,path_w], that is, [1.0,[1,0]] is stored in Q[0].
The searching unit 22 also executes the same calculations on the unprocessed [3,2.0] and stores [2.0,[3,0]] in Q[0]. When this processing ends, the values are set at the columns of “0” at Q, q[1], q[3], and P[0] as illustrated in
Up to this point, the adjacent vertex processing for v ends, and the extension processing for v ends. Returning to S16 in
More specifically, for example, as illustrated in
First, searching processing on the starting point side is executed. As illustrated in
Also, as illustrated in
Next, searching processing on the end point side is executed. As illustrated in
This processing will be described in more detail. First, the searching unit 22 takes out [1.0,[1,0]] at the beginning of Q[0] and [1.0,[5,8]] in Q[1] and executes the same processing as the processing described with reference to
Because paths reaches the vertex 2 and the vertex 4 from both of the starting point to the end point, it appears that a shortest path from the starting point to the end point is formed by jointing them. However, it is not trues Certainly, paths from the starting point and the end point to the vertex 2 and the vertex 4 are stored in the queues Q[0] and Q[1] as shortest path candidates, but they are only candidates. When they are taken out from the queue, the partial shortest path from the starting point or end point to the vertex is fixed among all candidates that are not taken out (including those that have not been put into the queue). In other words, for example, if the shortest path to the vertex has not been taken out, the taken path is guaranteed as a shortest path from the starting point or the end point to the vertex. When i paths have already reached, it is guaranteed to be the (i+1)th shortest path. Conversely, even when candidates stored in the queues Q[0] and Q[1] are jointed, it is not clear which ones are jointed.
More specifically, for example, as illustrated in
First, searching processing on the starting point side is executed. As illustrated in
Also, as illustrated in
Next, searching processing on the end point side is executed. As illustrated in
Also for the vertex 4 adjacent to the vertex 7, as a path (length) from the end point to the vertex 4, the searching unit 22 calculates a total length “3.0” acquired by adding the length “1.0” from the vertex 8 to the vertex 7 and the length “2.0” from the vertex 7 to the vertex 4. The searching unit 22 tries to store the total length “3.0” in q[4][1] of the vertex 4. However, “2.0” has already been stored in q[4][1], the condition that the number of stored paths is lower than pmax is not satisfied, and the stored length is equal to or lower than the calculated length. Therefore, the searching unit 22 abandons the total length without storing it. As a result, the searching unit 22 does not store the path information [3.0,[4,7,8]] to the vertex 4 in the starting point side priority queue Q[1].
This processing will be described in more detail. The adjacent vertex processing is performed on the vertex 3 and the vertex 7 so that the data structures in FIG, 18 may be acquired. In the adjacent vertex processing from the vertex 3 to the vertex 4 in the processing, [w,edge_length]=[4,1.0] is processed in S31 in
First, as illustrated in
The searching unit 22 executes the same processing on the vertex 1 adjacent to the vertex 2 to be processed so that the searching unit 22 takes out [2.0,[2,5,8]] at the beginning from the end point side priority queue “Q[1]” and stores [2.0,[2,5,8]] in P[2][1] corresponding to the vertex 2 to be processed. The searching unit 22 calculates a length “1.0+1.0+1.0=10” from the vertex 8 being the end point to the vertex 1 and stores [3.0] in q[1][1]. The searching unit 22 stores path information [3.0,[1,2,5,8]] from the end point 8 to the vertex 1 in the end point side priority queue Q[1].
Because values are stored in P[2][0] and P[2][1], the searching unit 22 determines that the vertex 2 is a joint point. The searching unit 22 then combines the path [2,1,0] from the starting point to the vertex 2 and the path [2,5,8] from the end point to the vertex 2 to generate a path [0,1,2,5,8]. The searching unit 22 further combines the length “2.0” of the path from the starting point to the vertex 2 and the length [2.0] of the path from the end point to the vertex 2 to calculate the length of the path [0,1,2,5,8] as [4.0]. Because data is not stored in totalQ, the searching unit 22 stores the path information “4.0[0,1,2,5,8]” as a shortest path in totalQ.
This processing will be described in more detail. [2.0,[2,1,0]] is taken out from Q[0], and [2.0,[2,5,8]] is taken out from Q[1]. Therefore, the shortest path from the starting point and the shortest path from the end point are jointed at the vertex 2 for the first time. In other words, the vertex 2 is now a joint point. When i=1 in
First, searching processing on the starting point side is executed. As illustrated in
Therefore, the searching unit 22 abandons the total length without storing it. As a result, the searching unit 22 does not store the path information [4.0,[5,4,1,0]] to the vertex 5 in the starting point side priority queue Q[0].
Also, as illustrated in
Next, searching processing on the end point side is executed. As illustrated in
The searching unit 22 also executes the same processing on the vertex 1 on the end point side and calculates a total of “4.0” of the length of the path via the vertex 8, the vertex 5, the vertex 4, and the vertex 1 as a path (length) from the end point to the vertex 1. The searching unit 22 tries to store the length “4.0” in q[1][1] of the vertex 1. However, “3.0” has already been stored in q[1][1], the condition that the number of stored paths is lower than pmax is not satisfied, and the stored length is equal to or lower than the calculated length. Therefore, the searching unit 22 abandons the total length without storing it. As a result, the searching unit 22 does not store the path information [4.0,[1,4,5,8]] to the vertex 1 in the end point side priority queue Q[1].
Because values are stored in P[4][0] and P[4][1], the searching unit 22 determines that the vertex 4 is a joint point. The searching unit 22 then combines the path [4,1,0] from the starting point to the vertex 4 and the path [4,5,8] from the end point to the vertex 4 to generate a path [0,1,4,5,8]. The searching unit 22 further combines the length “3.0” of the path from the starting point to the vertex 4 and the length [2.0] of the path from the end point to the vertex 4 to calculate the length of the path [0,1,4,5,8] as [5.0]. Because data to be stored in totalQ is lower than 2 (=k), the searching unit 22 stores the path information “5.0[0,1,4,5,8]” as a shortest path in totalQ.
By executing the aforementioned processing, the adjacent vertex processing illustrated in
More specifically, for example, as illustrated in
First, searching processing on the starting point side is executed. As illustrated in
Also, as illustrated in
Next, searching processing on the end point side is executed. As illustrated in
Because values are stored in P[5][0] and P[5][1], the searching unit 22 determines that the vertex 5 is a joint point. The searching unit 22 then combines the path [5,2,1,0] from the starting point to the vertex 5 and the path [5,8] from the end point to the vertex 5 to generate a path [0,1,2,5,8]. The searching unit 22 further combines the length “3.0” of the path from the starting point to the vertex 5 and the length [1,0] of the path from the end point to the vertex 5 to calculate the length of the path [0,1,2,5,8] as [4.0]. The searching unit 22 tries to store the path information [4.0,[0,1,2,5,8]] in totalQ. However, because it has been already stored, the path information is abandoned.
This processing will be described in more detail. When the adjacent vertex processing is executed on the vertex 5 and the vertex 6 as before, the adjacent vertex processing is not performed on the vertex 6. As a result, the data structures illustrated in
More specifically, for example, as illustrated in
First, searching processing on the starting point side is executed. As illustrated in
Next, searching processing on the end point side is executed. As illustrated in
Regarding the vertex 4 adjacent to the vertex 1, because the path having a length of 2 has already reached from the end point to the vertex 4 (q[4][1]=[2.0]), the processing is ended.
By performing the aforementioned processing, the adjacent vertex processing is executed on the vertex 6 and the vertex 1. The processing is performed on the vertex 1 as before, but the adjacent vertex processing is not performed on the vertex 6. As a result, the data structures illustrated in
This processing continues also after this, However, the storage in Q[0] and Q[1] is suspended, and both of Q[0] and Q[1] become empty. At that time, based on the condition in S11 in
Based on the descriptions above, an overview of the acquisition of a shortest path through combination of partial shortest paths at joint points will be described with reference to
Next, optimization of the parameter α will be described. The optimization of the parameter α corresponds to a search for an optimum parameter by changing the value of pmax in a range from 1 to k within a range equal to or higher than the user acceptable precision Pmin. The inclusion of k guarantees acquisition of the parameter with a precision of 1.0 even when Pmin=1.0 is designated. However, there is a possibility that the processing takes enormous time particularly when the value of pmax is close to k during the processing of changing the value pmax in a range from 1 to k. This is avoided as follows. Generally, as the value of pmax decreases, the searching time decreases,
On the other hand, based on the experiment as will be described below, for example, the precision 1.0 is acquired as a result of reduction of the value of pmax. In view of this, pmax is started to be changed from 1, and the change is ended when the precision exceeds Pmin. By doing so, it may be expected to perform the optimization at a high speed.
As illustrated in
Next, 1 is substituted for p_max (S42). If p_max is equal to or lower than k (S43: Yes), a function find_app is executed in S44. More specifically, for example, find_app(v_list,source_vid,target_vid,k,p_max) is a function that performs k-shortest path search by approximation. The parameters and return values of the function are similar to those of find_acc, but they are different in that p_max that is a maximum number of paths is added to the parameters. spl_app is a similar list to spl_acc, and they completely agree if calculations go right. However, because spl_app is acquired by approximation, spl_app may not include all of those included in spl_acc. This list is one returned in S12 in
After that, if precision acquired in S44 is lower than Pmin (S45: No), p_max is incremented (S47), and the processing in S43 and subsequent steps is executed. On the other hand, if precision acquired in S44 is equal to or higher than Pmin (S45: Yes), S46 is executed, and the processing ends. By performing this checking processing up to p_max=k, an accurate solution is acquired without fail even Pmin=1.0 is designated. If α is not acquired even by performing the checking processing up to p_max=k, an error occurs or the processing abnormally ends.
In this example, the processing is ended because a precision of 1.0 is acquired with a significantly low pmax. The value of a to be acquired is calculated by using the value of pmax when the processing is ended. Against values 16, 32, and 64 of k, the values of a are dose to each other as 0.75, 0.707, and 0.5, respectively. By adopting α=0.75, which is the highest value of the values, it may be expected that the precision is 1.0 or close to that independently of the value of k. If the precision requirement is not so strict, 0.65, which is the average of the values, may be applied. Conversely, if the precision requirement is more strict, the value of α may be higher with a certain margin. For simple description, one measurement is performed on one pair of a starting point and an end point. However, in order to actually determine α, k may be changed in its usable range, and various starting points and end points may be applied to acquire the maximum value or average value of a for effectively performing statistic processing.
Next, effects of the methods according to Embodiments 1 to 3 will be described, Effects by the presence of approximation, reduction effects by max, and a comparison with extended Dijkstra will be described.
The performance ratio is a ratio of the processing time in a case where reduction by max is not applied against the processing time in a case where reduction by max is applied. In other words, for example, the performance ratio indicates how many times the processing speed increases by applying reduction by max. When approximation is used, the processing speed increases by 3.4 to 9.5 times. This indicates that, as the number of vertices increases, the performance ratio increases. When approximation is not used, the processing speed increases by 8.0 to 12.2 times. This may indicate that, as the number of vertices increases, the performance ratio tends to increase though the processing speed decreases at some parts.
As illustrated in
As illustrated in
While an embodiment of the present disclosure has been described, the present disclosure may be implemented in various different forms other than the embodiment described above.
A shortest path on an unweighted graph may be acquired at a high speed by using breadth-first search as known well. This may be easily implemented by using general “first-in, first-out” queues instead of priority queues. Even the method according to the embodiments may easily address unweighted graphs by replacing the priority queues by general queues. The method according to the embodiments may also address unweighted graphs by defining all weights as LO, but the processing speed is more increased by using breadth-first search.
Dijkstra method may address a directed graph. Therefore, the method according to the embodiments may be easily improved so as to address a directed graph. More specifically, when vertices v and w are adjacent to each other, data structures indicating edges are stored in adj_edge_list of v and w on an undirected graph. However, on a directed graph, an edge having a direction from v to w is only added to adj_edge_list of v. If the edge is bidirectional, it is also added to adj_edge_list of w. With these changes, the method according to the embodiments may address directed graphs.
Processing procedures, control procedures, specific names, and information containing various kinds of data and parameters indicated in the specification and the drawings may be changed in any manner unless otherwise specified. The specific examples, distributions, numerical values, and so on described in the embodiments are merely examples and may be arbitrarily changed,
The constituent elements of the devices illustrated in the drawings are functional conceptual ones and not necessarily configured physically as illustrated in the drawings. Specific forms of distribution and integration of the devices are not limited to those illustrated in the drawings. All or some of the devices may be functionally or physically distributed or integrated in any unit based on various loads, usage statuses, or the like. All or some of the processing functions performed by the devices may be implemented by a central processing unit (CPU) and a program analyzed and run by the CPU or may be implemented by a hardware device using wired logic coupling.
The communication device 10a is, for example, a network interface card and communicates with a server. The HDD 10b stores a program and DBs that implement functions illustrated in
The processor 10d executes processes that implement the functions illustrated in, for example,
As described above, the searching apparatus 10 functions as an information processing apparatus that implements a searching method by reading and running the program. The searching apparatus 10 may also implement the same functions as those of the embodiments described above by reading the program from a recording medium with the use of a medium reading device and running the read program. The program described in other embodiments is not limited to a program that is run by the searching apparatus 10. For example, the disclosure is applicable to the case in which another computer or a server runs the program or the case in which the other computer and the server cooperate to run the program.
The program may be distributed via a network such as the Internet. The program may be recorded on a computer-readable recording medium such as a hard disk, a flexible disk (FD), a compact disc read-only memory (CD-ROM), a magneto-optical disk (MO), a digital versatile disc (DVD), or the like, and may be executed after being read from the recording medium by a computer.
All examples and conditional language provided herein are intended for the pedagogical purposes of aiding the reader in understanding the invention and the concepts contributed by the inventor to further the arcs and are not to be construed as limitations to such specifically recited examples and conditions, nor does the organization of such examples in the specification relate to a showing of the superiority and inferiority of the invention. Although one or more embodiments of the present invention have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
Number | Date | Country | Kind |
---|---|---|---|
2019-025655 | Feb 2019 | JP | national |