Difference between revisions of "Dijkstra algorithm"
(Importing text file) |
(TeX done) |
||
Line 1: | Line 1: | ||
+ | {{TEX|done}}{{MSC|05C85}} | ||
+ | |||
''Dijkstra shortest-path algorithm'' | ''Dijkstra shortest-path algorithm'' | ||
− | Let | + | Let $\Gamma=(V(\Gamma),E(\Gamma))$ be a [[graph]] with a specified vertex $s$ and for every edge $e \in E(\Gamma)$ a non-negative cost (length) $c(e)$. The shortest-path problem is to find a least cost (shortest) path from $s$ to every other vertex (node) $i$. |
− | Basically, the Dijkstra algorithm, which solves this problem, is a node-labeling [[ | + | Basically, the Dijkstra algorithm, which solves this problem, is a node-labeling [[greedy algorithm]]. It proceeds by constructing, one node at a time, a subtree $T$ rooted at $s$ (an $s$-[[arborescence]]). If $\Gamma$ is connected, $T$ will be a spanning subtree (at the end). |
− | Initially, | + | Initially, $T = \{s\}$. At any further step one knows the shortest distance $d(s,v)$ and corresponding path from $s$ to any vertex $v \in T$. This is the label of $v$. Of course, $d(s,s) = 0$. |
− | Now, look through | + | Now, look through $V(\Gamma) \setminus V(T)$ for a vertex $v \in V(\Gamma) \setminus V(T)$ and a $u \in V(T)$ for which $d(s,v) + d(vu)$ is minimal, and add $v$ and the edge $vu$ to $T$. |
− | The algorithm stops as soon as | + | The algorithm stops as soon as $T$ spans the connected component of $s$ in $\Gamma$. The shortest path from $s$ to any $v$ in the connected component of $s$ in $\Gamma$ is given by the unique path in $T$ from $s$ to $v$; the length is $d(s,v)$. |
− | A very rough implementation of Dijkstra's algorithm takes | + | A very rough implementation of Dijkstra's algorithm takes $O(mn)$ steps, where $n$ is, the cardinality of the vertex set $V(\Gamma)$, and $m$ is the cardinality of the set of edge set $E(\Gamma)$. It can be done much more efficiently, [[#References|[a3]]]. |
The algorithm can be easily adapted to directed edge-weighted graphs and networks. As of 2001, there is no efficient algorithm for finding longest paths in loop-free (directed) graphs. | The algorithm can be easily adapted to directed edge-weighted graphs and networks. As of 2001, there is no efficient algorithm for finding longest paths in loop-free (directed) graphs. | ||
====References==== | ====References==== | ||
− | <table><TR><TD valign="top">[a1]</TD> <TD valign="top"> A. Frank, "Connectivity and network flows" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , ''Handbook of Combinatorics'' , Elsevier (1995) pp. 111–178</TD></TR><TR><TD valign="top">[a2]</TD> <TD valign="top"> "Encyclopedia of Operations Research and Management Science" S.I. Gass (ed.) C.M. Harris (ed.) , Kluwer Acad. Publ. (1996) pp. 166–167</TD></TR><TR><TD valign="top">[a3]</TD> <TD valign="top"> L. Lovász, D.B. Shmoys, E. Tardos, "Combinatorics in computer science" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , ''Handbook of Combinatorics'' , Elsevier (1995) pp. 2003–2038</TD></TR></table> | + | <table> |
+ | <TR><TD valign="top">[a1]</TD> <TD valign="top"> A. Frank, "Connectivity and network flows" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , ''Handbook of Combinatorics'' , Elsevier (1995) pp. 111–178</TD></TR> | ||
+ | <TR><TD valign="top">[a2]</TD> <TD valign="top"> "Encyclopedia of Operations Research and Management Science" S.I. Gass (ed.) C.M. Harris (ed.) , Kluwer Acad. Publ. (1996) pp. 166–167</TD></TR> | ||
+ | <TR><TD valign="top">[a3]</TD> <TD valign="top"> L. Lovász, D.B. Shmoys, E. Tardos, "Combinatorics in computer science" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , ''Handbook of Combinatorics'' , Elsevier (1995) pp. 2003–2038</TD></TR> | ||
+ | </table> |
Revision as of 19:40, 6 September 2017
2020 Mathematics Subject Classification: Primary: 05C85 [MSN][ZBL]
Dijkstra shortest-path algorithm
Let $\Gamma=(V(\Gamma),E(\Gamma))$ be a graph with a specified vertex $s$ and for every edge $e \in E(\Gamma)$ a non-negative cost (length) $c(e)$. The shortest-path problem is to find a least cost (shortest) path from $s$ to every other vertex (node) $i$.
Basically, the Dijkstra algorithm, which solves this problem, is a node-labeling greedy algorithm. It proceeds by constructing, one node at a time, a subtree $T$ rooted at $s$ (an $s$-arborescence). If $\Gamma$ is connected, $T$ will be a spanning subtree (at the end).
Initially, $T = \{s\}$. At any further step one knows the shortest distance $d(s,v)$ and corresponding path from $s$ to any vertex $v \in T$. This is the label of $v$. Of course, $d(s,s) = 0$.
Now, look through $V(\Gamma) \setminus V(T)$ for a vertex $v \in V(\Gamma) \setminus V(T)$ and a $u \in V(T)$ for which $d(s,v) + d(vu)$ is minimal, and add $v$ and the edge $vu$ to $T$.
The algorithm stops as soon as $T$ spans the connected component of $s$ in $\Gamma$. The shortest path from $s$ to any $v$ in the connected component of $s$ in $\Gamma$ is given by the unique path in $T$ from $s$ to $v$; the length is $d(s,v)$.
A very rough implementation of Dijkstra's algorithm takes $O(mn)$ steps, where $n$ is, the cardinality of the vertex set $V(\Gamma)$, and $m$ is the cardinality of the set of edge set $E(\Gamma)$. It can be done much more efficiently, [a3].
The algorithm can be easily adapted to directed edge-weighted graphs and networks. As of 2001, there is no efficient algorithm for finding longest paths in loop-free (directed) graphs.
References
[a1] | A. Frank, "Connectivity and network flows" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , Handbook of Combinatorics , Elsevier (1995) pp. 111–178 |
[a2] | "Encyclopedia of Operations Research and Management Science" S.I. Gass (ed.) C.M. Harris (ed.) , Kluwer Acad. Publ. (1996) pp. 166–167 |
[a3] | L. Lovász, D.B. Shmoys, E. Tardos, "Combinatorics in computer science" R.L. Graham (ed.) M. Grötschel (ed.) L. Lovász (ed.) , Handbook of Combinatorics , Elsevier (1995) pp. 2003–2038 |
Dijkstra algorithm. Encyclopedia of Mathematics. URL: http://encyclopediaofmath.org/index.php?title=Dijkstra_algorithm&oldid=11354