Copyright © Philip M. Parker, INSEAD. Terms of Use.

| Domain | Definition |
Math | An algorithm to find the shortest paths from a single source vertex to all other vertices in a weighted, directed graph. All weights must be nonnegative. Implementing the priority queue with a Fibonnaci heap makes the time complexity O(E + V log V), where V is the number of vertices and E is the number of edges. (references) |
Source: compiled by the editor from various references; see credits. | |
(From Wikipedia, the free Encyclopedia)
Dijkstra's algorithm, named after its inventor the Dutch computer scientist Edsger Dijkstra, solves a shortest path problem for a directed and connected graph G(V,E) which has nonnegative (>=0) edge weights. The set V is the set of all vertices in the graph G. The set E is the set of ordered pairs which represent connected vertexes in the graph (if (u,v) belongs to E then there is a connection from vertex u to vertex v).
Assume that the function w: V x V -> [0, ∞] describes the cost w(x,y) of moving from vertex x to vertex y (non-negative cost). (We can define the cost to be infinite for pairs of vertices that are not connected by an edge.) The cost of a path between two vertices is the sum of costs of the edges in that path. The cost of an edge can be thought of as (a generalisation of) the distance between those two vertices. For a given pair of vertices s,t in V, the algorithm finds the path from s to t with lowest cost (i.e. the shortest path).
The algorithm works by constructing a subgraph S of such that the distance of any vertex v' (in S) from s is known to be a minimum within G. Initially S is simply the single vertex s, and the distance of s from itself is known to be zero. Edges are added to S at each stage by (a) identifying all the edges ei = (vi1,vi2) in G-S such that vi1 is in S and vi2 is in G, and then (b) choosing the edge ej = (vj1,vj2) in G-S which gives the minimum distance of its vertex vj2 (in G) from s from all edges ei. The algorithm terminates either when S becomes a spanning tree of G, or when all the vertices of interest are within S.
The procedure for adding an edge ej to S maintains the property that the distances of all the vertices within S from s are known to be minimum.
A few subroutines for use with Dijkstra's algorithm:
Initialize-Single-Source(G,s)
1 for each vertex v in V[G] 2 do d[v] := infinite 3 previous[v] := 0 4 d[s] := 0Relax(u,v,w)
1 if d[v] > d[u] + w(u,v) 2 then d[v] := d[u] + w(u,v) 3 previous[v] := uv = Extract-Min(Q) searches for the vertex v in the vertex set Q that has the least d[v] value. That vertex is removed from the set Q and then returned.
The algorithm:
Dijkstra(G,w,s)
1 Initialize-Single-Source(G,s)
2 S := empty set
3 Q := set of all vertexes
4 while Q is not an empty set
5 do u := Extract-Min(Q)
6 S := S union {u}
7 for each vertex v which is a neighbour of u
8 do Relax(u,v,w)
Dijkstra's algorithm can be implemented efficiently by storing the graph in the form of adjacency lists and using a heap as priority queue to implement the Extract-Min function.
If the graph has m edges and n vertices, then the algorithm's time requirements are Θ(m + n log n) (see Big O notation), assuming that comparisons of edge weights take constant time. If we are only interested in a shortest path between vertexes s and t, we can terminate the search at line 5 if u == t.
Now we can read the shortest path from s to t by iteration:
1 S = empty sequence 2 u := t 3 S = u + S /* insert u to the beginning of S */ 4 if u == s 5 end 6 u = previous[u] 7 goto 3Now sequence S has the shortest path from s to t.
OSPF Open shortest path first is a well known real world implementation used in internet routing.
A related problem is the traveling salesman problem, which is the problem of finding the shortest path that goes through every vertex exactly once, and returns to the start. That problem is NP-hard, so it can't be solved by Dijkstra's algorithm, nor by any other known, polynomial-time algorithm.
See Also
References
Source: adapted by the editor from Wikipedia, the free encyclopedia under a copyleft GNU Free Documentation License (GFDL) from the article "Dijkstra's algorithm."
Crosswords: DIJKSTRA'S ALGORITHM |
| Specialty definitions using "DIJKSTRA'S ALGORITHM": Johnson's algorithm ♦ single-source shortest-path problem. (references) |
Hexadecimal (or equivalents, 770AD-1900s) (references)44 49 4A 4B 53 54 52 41 27 53      41 4C 47 4F 52 49 54 48 4D |
| Leonardo da Vinci (1452-1519; backwards) (references)
|
Binary Code (1918-1938, probably earlier) (references)01000100 01001001 01001010 01001011 01010011 01010100 01010010 01000001 00100111 01010011 00100000 01000001 01001100 01000111 01001111 01010010 01001001 01010100 01001000 01001101 |
HTML Code (1990) (references)D I J K S T R A ' S   A L G O R I T H M |
ISO 10646 (1991-1993) (references)0044 0049 004A 004B 0053 0054 0052 0041 0027 0053      0041 004C 0047 004F 0052 0049 0054 0048 004D |
Encryption (beginner's substitution cypher): (references)38434445535452359532354641495243544247 |
| 1. Crosswords 2. Orthography 3. Bibliography |
Copyright © Philip M. Parker, INSEAD. Terms of Use.