Shortest path problem explained

In graph theory, the shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized.

The problem of finding the shortest path between two intersections on a road map may be modeled as a special case of the shortest path problem in graphs, where the vertices correspond to intersections and the edges correspond to road segments, each weighted by the length of the segment.

Definition

The shortest path problem can be defined for graphs whether undirected, directed, or mixed. Here it is defined for undirected graphs; for directed graphs the definition of path requires that consecutive vertices be connected by an appropriate directed edge.[1]

Two vertices are adjacent when they are both incident to a common edge.A path in an undirected graph is a sequence of vertices

P=(v1,v2,\ldots,vn)\inV x V x x V

such that

vi

is adjacent to

vi+1

for

1\leqi<n

.Such a path

P

is called a path of length

n-1

from

v1

to

vn

.(The

vi

are variables; their numbering here relates to their position in the sequence and needs not to relate to any canonical labeling of the vertices.)

Let

E=\{ei,\}

where

ei,

is the edge incident to both

vi

and

vj

. Given a real-valued weight function

f:ER

, and an undirected (simple) graph

G

, the shortest path from

v

to

v'

is the path

P=(v1,v2,\ldots,vn)

(where

v1=v

and

vn=v'

) that over all possible

n

minimizes the sum
n-1
\sum
i=1

f(ei,).

When each edge in the graph has unit weight or

f:E\{1\}

, this is equivalent to finding the path with fewest edges.

The problem is also sometimes called the single-pair shortest path problem, to distinguish it from the following variations:

These generalizations have significantly more efficient algorithms than the simplistic approach of running a single-pair shortest path algorithm on all relevant pairs of vertices.

Algorithms

Several well known algorithms exist for solving this problem and its variants.

Additional algorithms and associated evaluations may be found in .

Single-source shortest paths

Undirected graphs

Weights Author

R

+
O(V2)

R

+
O((E + V) log V) (binary heap)

R

+
O(E + V log V) (Fibonacci heap)

N

O(E) (requires constant-time multiplication)

Directed acyclic graphs (DAGs)

An algorithm using topological sorting can solve the single-source shortest path problem in time in arbitrarily-weighted DAGs.

Directed graphs with nonnegative weights

The following table is taken from, with some corrections and additions.A green background indicates an asymptotically best bound in the table; L is the maximum length (or weight) among all edges, assuming integer edge weights.

Weights Algorithm Time complexity Author

R

O(V2EL)

R

O(VE)

,,

R

O(V2log{V})

R

Dijkstra's algorithm with list

O(V2)

,, Minty (see),

R

O((E+V)log{V})

R

Dijkstra's algorithm with Fibonacci heap

O(E+Vlog{V})

,

R

Quantum Dijkstra algorithm with adjacency list

O(\sqrt{VE}log2{V})

Dürr et al. 2006[2]

N

Dial's algorithm[3] (Dijkstra's algorithm using a bucket queue with L buckets)

O(E+LV)

O(Elog{log{L}})

,

O(ElogE/VL)

,

O(E+V\sqrt{log{L}})

N

Thorup

O(E+Vlog{log{V}})

Directed graphs with arbitrary weights without negative cycles

Weights Algorithm Time complexity Author

R

O(V2EL)

R

O(VE)

,,

R

O(VE+VlogV)

R

O(VE+VlogV)

,, adapted after

Z

Johnson's technique applied to Dial's algorithm

O(V(E+L))

, adapted after

Z

Interior-point method with Laplacian solver

O(E10/7logO(1)VlogO(1)L)

Z

Interior-point method with

\ellp

flow solver

E4/3logO(1)L

Z

Robust interior-point method with sketching

O((E+V3/2)logO(1)VlogO(1)L)

Z

\ell1

interior-point method with dynamic min-ratio cycle data structure

O(E1+o(1)logL)

Z

Based on low-diameter decomposition

O(Elog8VlogL)

R

Hop-limited shortest paths

O(EV8/9logO(1)V)

Directed graphs with arbitrary weights with negative cycles

Finds a negative cycle or calculates distances to all vertices.

Planar graphs with nonnegative weights

All-pairs shortest paths

The all-pairs shortest path problem finds the shortest paths between every pair of vertices, in the graph. The all-pairs shortest paths problem for unweighted directed graphs was introduced by, who observed that it could be solved by a linear number of matrix multiplications that takes a total time of .

Undirected graph

Weights Time complexity Algorithm

R

+
Floyd–Warshall algorithm

\{1,infty\}

O(V\omegalogV)

Seidel's algorithm (expected running time)

N

O(V3/2

\Omega(logV)1/2

)

R

+

N

applied to every vertex (requires constant-time multiplication).

Directed graph

Weights Time complexity Algorithm

R

(no negative cycles)

O(V3)

Floyd–Warshall algorithm

N

O(V3/2

\Omega(logV)1/2

)

R

(no negative cycles)

O(V2.5log2{V})

Quantum search[4] [5]

R

(no negative cycles)
Johnson–Dijkstra

R

(no negative cycles)

N

Applications

Shortest path algorithms are applied to automatically find directions between physical locations, such as driving directions on web mapping websites like MapQuest or Google Maps. For this application fast specialized algorithms are available.[6]

If one represents a nondeterministic abstract machine as a graph where vertices describe states and edges describe possible transitions, shortest path algorithms can be used to find an optimal sequence of choices to reach a certain goal state, or to establish lower bounds on the time needed to reach a given state. For example, if vertices represent the states of a puzzle like a Rubik's Cube and each directed edge corresponds to a single move or turn, shortest path algorithms can be used to find a solution that uses the minimum possible number of moves.

In a networking or telecommunications mindset, this shortest path problem is sometimes called the min-delay path problem and usually tied with a widest path problem. For example, the algorithm may seek the shortest (min-delay) widest path, or widest shortest (min-delay) path.

A more lighthearted application is the games of "six degrees of separation" that try to find the shortest path in graphs like movie stars appearing in the same film.

Other applications, often studied in operations research, include plant and facility layout, robotics, transportation, and VLSI design.[7]

Road networks

A road network can be considered as a graph with positive weights. The nodes represent road junctions and each edge of the graph is associated with a road segment between two junctions. The weight of an edge may correspond to the length of the associated road segment, the time needed to traverse the segment, or the cost of traversing the segment. Using directed edges it is also possible to model one-way streets. Such graphs are special in the sense that some edges are more important than others for long-distance travel (e.g. highways). This property has been formalized using the notion of highway dimension.[8] There are a great number of algorithms that exploit this property and are therefore able to compute the shortest path a lot quicker than would be possible on general graphs.

All of these algorithms work in two phases. In the first phase, the graph is preprocessed without knowing the source or target node. The second phase is the query phase. In this phase, source and target node are known. The idea is that the road network is static, so the preprocessing phase can be done once and used for a large number of queries on the same road network.

The algorithm with the fastest known query time is called hub labeling and is able to compute shortest path on the road networks of Europe or the US in a fraction of a microsecond.[9] Other techniques that have been used are:

Related problems

For shortest path problems in computational geometry, see Euclidean shortest path.

The shortest multiple disconnected path [10] is a representation of the primitive path network within the framework of Reptation theory. The widest path problem seeks a path so that the minimum label of any edge is as large as possible.

Other related problems may be classified into the following categories.

Paths with constraints

Unlike the shortest path problem, which can be solved in polynomial time in graphs without negative cycles, shortest path problems which include additional constraints on the desired solution path are called Constrained Shortest Path First, and are harder to solve. One example is the constrained shortest path problem,[11] which attempts to minimize the total cost of the path while at the same time maintaining another metric below a given threshold. This makes the problem NP-complete (such problems are not believed to be efficiently solvable for large sets of data, see P = NP problem). Another NP-complete example requires a specific set of vertices to be included in the path,[12] which makes the problem similar to the Traveling Salesman Problem (TSP). The TSP is the problem of finding the shortest path that goes through every vertex exactly once, and returns to the start. The problem of finding the longest path in a graph is also NP-complete.

Partial observability

The Canadian traveller problem and the stochastic shortest path problem are generalizations where either the graph is not completely known to the mover, changes over time, or where actions (traversals) are probabilistic.[13] [14]

Strategic shortest paths

Sometimes, the edges in a graph have personalities: each edge has its own selfish interest. An example is a communication network, in which each edge is a computer that possibly belongs to a different person. Different computers have different transmission speeds, so every edge in the network has a numeric weight equal to the number of milliseconds it takes to transmit a message. Our goal is to send a message between two points in the network in the shortest time possible. If we know the transmission-time of each computer (the weight of each edge), then we can use a standard shortest-paths algorithm. If we do not know the transmission times, then we have to ask each computer to tell us its transmission-time. But, the computers may be selfish: a computer might tell us that its transmission time is very long, so that we will not bother it with our messages. A possible solution to this problem is to use a variant of the VCG mechanism, which gives the computers an incentive to reveal their true weights.

Negative cycle detection

In some cases, the main goal is not to find the shortest path, but only to detect if the graph contains a negative cycle. Some shortest-paths algorithms can be used for this purpose:

O(|V||E|)

.

General algebraic framework on semirings: the algebraic path problem

Many problems can be framed as a form of the shortest path for some suitably substituted notions of addition along a path and taking the minimum. The general approach to these is to consider the two operations to be those of a semiring. Semiring multiplication is done along the path, and the addition is between paths. This general framework is known as the algebraic path problem.[16] [17] [18]

Most of the classic shortest-path algorithms (and new ones) can be formulated as solving linear systems over such algebraic structures.[19]

More recently, an even more general framework for solving these (and much less obviously related problems) has been developed under the banner of valuation algebras.[20]

Shortest path in stochastic time-dependent networks

In real-life situations, the transportation network is usually stochastic and time-dependent. In fact, a traveler traversing a link daily may experiences different travel times on that link due not only to the fluctuations in travel demand (origin-destination matrix) but also due to such incidents as work zones, bad weather conditions, accidents and vehicle breakdowns. As a result, a stochastic time-dependent (STD) network is a more realistic representation of an actual road network compared with the deterministic one.[21] [22]

Despite considerable progress during the course of the past decade, it remains a controversial question how an optimal path should be defined and identified in stochastic road networks. In other words, there is no unique definition of an optimal path under uncertainty. One possible and common answer to this question is to find a path with the minimum expected travel time. The main advantage of using this approach is that efficient shortest path algorithms introduced for the deterministic networks can be readily employed to identify the path with the minimum expected travel time in a stochastic network. However, the resulting optimal path identified by this approach may not be reliable, because this approach fails to address travel time variability. To tackle this issue some researchers use distribution of travel time instead of expected value of it so they find the probability distribution of total travelling time using different optimization methods such as dynamic programming and Dijkstra's algorithm .[23] These methods use stochastic optimization, specifically stochastic dynamic programming to find the shortest path in networks with probabilistic arc length.[24] The concept of travel time reliability is used interchangeably with travel time variability in the transportation research literature, so that, in general, one can say that the higher the variability in travel time, the lower the reliability would be, and vice versa.

In order to account for travel time reliability more accurately, two common alternative definitions for an optimal path under uncertainty have been suggested. Some have introduced the concept of the most reliable path, aiming to maximize the probability of arriving on time or earlier than a given travel time budget. Others, alternatively, have put forward the concept of an α-reliable path based on which they intended to minimize the travel time budget required to ensure a pre-specified on-time arrival probability.

See also

References

Bibliography

Further reading

Notes and References

  1. Book: Deo . Narsingh . Graph Theory with Applications to Engineering and Computer Science . 17 August 2016 . Courier Dover Publications . 978-0-486-80793-5 . en.
  2. Dürr . Christoph . Heiligman . Mark . Høyer . Peter . Mhalla . Mehdi . January 2006 . Quantum query complexity of some graph problems . SIAM Journal on Computing . 35 . 6 . 1310–1328 . 10.1137/050644719 . quant-ph/0401091 . 14253494 . 0097-5397.
  3. Dial . Robert B. . Algorithm 360: Shortest-Path Forest with Topological Ordering [H] . Communications of the ACM . 12 . 11 . 632–633 . 1969 . 10.1145/363269.363610 . 6754003 . free .
  4. Dürr . C. . Høyer . P. . 1996-07-18 . A Quantum Algorithm for Finding the Minimum . quant-ph/9607014 .
  5. Nayebi . Aran . Williams . V. V. . 2014-10-22 . Quantum algorithms for shortest paths problems in structured instances . quant-ph . 1410.6220.
  6. Web site: Fast route planning . Peter . Sanders . Peter Sanders (computer scientist) . March 23, 2009 . Google Tech Talk . https://ghostarchive.org/varchive/youtube/20211211/-0ErpE8tQbw. 2021-12-11 . live.
  7. 10.1145/242224.242246 . Developing algorithms and software for geometric path planning problems . December 1996 . Danny Z. . Chen . ACM Computing Surveys . 28 . 4es . 11761485 . Article 18 .
  8. Abraham, Ittai; Fiat, Amos; Goldberg, Andrew V.; Werneck, Renato F. "Highway Dimension, Shortest Paths, and Provably Efficient Algorithms". ACM-SIAM Symposium on Discrete Algorithms, pages 782–793, 2010.
  9. Abraham, Ittai; Delling, Daniel; Goldberg, Andrew V.; Werneck, Renato F. research.microsoft.com/pubs/142356/HL-TR.pdf "A Hub-Based Labeling Algorithm for Shortest Paths on Road Networks". Symposium on Experimental Algorithms, pages 230–241, 2011.
  10. 10.1016/j.cpc.2005.01.020 . Shortest multiple disconnected path for the analysis of entanglements in two- and three-dimensional polymeric systems . 2005 . Martin . Kroger . Computer Physics Communications . 168 . 3 . 209–232 . 2005CoPhC.168..209K .
  11. Lozano . Leonardo . Medaglia . Andrés L . On an exact method for the constrained shortest path problem . Computers & Operations Research . 2013 . 40 . 1 . 378–384 . 10.1016/j.cor.2012.07.008.
  12. Book: Osanlou . Kevin . Bursuc . Andrei . Guettier . Christophe . Cazenave . Tristan . Jacopin . Eric . 2019 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS) . Optimal Solving of Constrained Path-Planning Problems with Graph Convolutional Networks and Optimized Tree Search . 2019 . 3519–3525 . 10.1109/IROS40897.2019.8968113 . 2108.01036 . 978-1-7281-4004-9 . 210706773 .
  13. Bar-Noy . Amotz . Schieber . Baruch . The canadian traveller problem . Proceedings of the Second Annual ACM-SIAM Symposium on Discrete Algorithms . 1991 . 261–270 . 10.1.1.1088.3015 .
  14. Nikolova . Evdokia . Karger . David R . Route planning under uncertainty: the Canadian traveller problem . Proceedings of the 23rd National Conference on Artificial Intelligence (AAAI) . 969–974 . https://ghostarchive.org/archive/20221009/https://www.aaai.org/Papers/AAAI/2008/AAAI08-154.pdf . 2022-10-09 . live.
  15. Cherkassky . Boris V. . Goldberg . Andrew V. . 1999-06-01 . Negative-cycle detection algorithms . Mathematical Programming . en . 85 . 2 . 277–311 . 10.1007/s101070050058 . 79739 . 1436-4646.
  16. Claude . Pair. Sur des algorithmes pour des problèmes de cheminement dans les graphes finis . On algorithms for path problems in finite graphs. Théorie des graphes (journées internationales d'études) [Theory of Graphs (international symposium)]. Dunod (Paris); Gordon and Breach (New York). 1967. Rome (Italy), July 1966. 271. Rosentiehl . Pierre . Pierre Rosenstiehl. 901424694.
  17. Book: Jean Claude . Derniame. Claude . Pair. Problèmes de cheminement dans les graphes . Path Problems in Graphs. Dunod (Paris). 1971.
  18. Book: John . Baras . George . Theodorakopoulos . Path Problems in Networks . 4 April 2010 . Morgan & Claypool Publishers . 978-1-59829-924-3 . 9–.
  19. Book: Michel . Gondran . Michel . Minoux . Graphs, Dioids and Semirings: New Models and Algorithms . 2008 . Springer Science & Business Media. 978-0-387-75450-5. chapter 4.
  20. Book: Marc . Pouly . Jürg . Kohlas . Generic Inference: A Unifying Theory for Automated Reasoning. 2011. John Wiley & Sons . 978-1-118-01086-0 . Chapter 6. Valuation Algebras for Path Problems.
  21. Loui, R.P., 1983. Optimal paths in graphs with stochastic or multidimensional weights. Communications of the ACM, 26(9), pp.670-676.
  22. Rajabi-Bahaabadi . Mojtaba . Afshin . Shariat-Mohaymany . Mohsen . Babaei . Chang Wook . Ahn . Multi-objective path finding in stochastic time-dependent road networks using non-dominated sorting genetic algorithm . Expert Systems with Applications . 2015 . 42 . 12. 5056–5064 . 10.1016/j.eswa.2015.02.046 .
  23. Olya . Mohammad Hessam . Finding shortest path in a combined exponential – gamma probability distribution arc length . International Journal of Operational Research . 2014 . 21 . 1. 25–37 . 10.1504/IJOR.2014.064020 .
  24. Olya . Mohammad Hessam . Applying Dijkstra's algorithm for general shortest path problem with normal probability distribution arc length . International Journal of Operational Research . 2014 . 21 . 2. 143–154 . 10.1504/IJOR.2014.064541 .