On The Optimization of Dijkstra's Algorithm
On The Optimization of Dijkstra's Algorithm
1 Introduction
2 Dijkstra’s Algorithm
The problem of finding the shortest path from a specified vertex s to mother t can be
stated as follows:
A simple weighted digraph G of n vertices is described by a n by n matrix D=[dij],
where, dij = length (or distance or weight) of the directed edge from vertex i to vertex
j:
> 0, if i ≠ j
d ij = = 0, if i = j
= ∞ (large number), if there is no edge from i to j
Dijkstra’s algorithm labels the vertices of the given digraph, At each stage in the
algorithm some vertices have permanent labels and others temporary labels. The
algorithm begins by assigning a permanent label 0 to the starting vertex s, and
temporary label infinity to the remaining n-1 vertices. From then on in each iteration,
another vertex sets a permanent label, according to the following rules:
a. Every vertex j that is not yet permanently labeled gets a new temporary
label whose value is given by min[old label of j, (old label of i + dij)],
where i is the latest vertex permanently labeled, in the previous iteration,
and dij is the direct distance between vertices i and j. If i and j are not
joined by an edge, then dij=infinity.
b. The smallest value among all the temporary labels is found, and this
becomes the permanent label of the corresponding vertex. In case of more
than one shortest path, select any one of the candidates for permanent
labeling. Steps a and b are repeated alternately until the destination vertex t
gets a permanent label. The first vertex to be permanently labeled is at a
distance of zero from s. The second vertex to get a permanent label (out of
the remaining n-1 vertices) is the vertex closest to s From the remaining n-
2 vertices, the next one to be permanently labeled is the second closest
vertex to s. And so on. The permanent label of each vertex is the shortest
distance of that vertex from s. This statement can be proved by induction.
The network in the following figure (figure 1) gives the distances in miles between
pairs of cities 1,2,… and 8. For efficiency purpose, we will find the shortest route
between cities 1 and 8 using the traditional and modified version of Dijkstra
algorithm:
0 1 0 0 0 0 0 0
0 0 1 0 2 0 0 0
0 0 0 2 0 4 0 0
0 0 0 0 0 0 0 0
T=
0 0 0 0 0 0 7 0
0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
4 Conclusion
4. Brendan, H., Gordon, J. Generalizing Dijkstra's Algorithm and Gaussian Elimination for
Solving MDPs. Conference: International Conference on Automated Planning and
Scheduling/Artificial Intelligence Planning Systems - ICAPS(AIPS) , pp. 151-160, 2005.
5. Ravi, N., Sireesha, V. Using Modified Dijkstra’s Algorithm for Critical Path Method in a
Project Network. International Journal of Computational and Applied Mathematics. Volume
5 number 2 pp 217-225. 2010.
6. Sudhakar, T.D.,Vadivoo, N.S., Slochanal, S.M.R., Ravichandran, S. Supply restoration in
distribution networks using Dijkstra's algorithm. International Conference on Power System
Technology, Signapure. 2004 (PowerCon 2004)