Académique Documents
Professionnel Documents
Culture Documents
Dijkstra Algorithm
Dijkstra Algorithm is named for Computer Scientist Edsgar Dijkstra, who proposed the
algorithms for finding the shortest path between two vertices. We start with the problem
of finding a shortest path from one vertex to another. Well concentrate simply on
finding the weight of the shortest path-in other words the smallest possible sum of
weights along a path from one vertex to another.
We will illustrate how the algorithm works with the following small graph:
V0
2
9
6
V5
V1
15
8
3
V3
6
1
V2
V4
The algorithm begins by filling in one value in the distance array. We fill with zero the
cell associated with the start vertex (there is an empty path from start vertex to itself).The
other values in the array are unknown and will be represented by infinity symbol .
This is the first version of the distance array
0
[0]
[1]
[2]
[3]
[4]
[5]
0
[0]
0
[0]
[1]
[1]
G={ V0 , V1}
[2]
10
[2]
[3]
17
[3]
[4]
[4]
[5]
8
[5]
[0]
[1]
10
[2]
17
11
[3]
[4]
[5]
G={ V0 , V1 , V5}
[0]
[1]
10
[2]
11
11
[3]
[4]
[5]
[0]
[1]
10
[2]
11
11
[3]
[4]
[5]
[0]
[1]
10
[2]
11
11
[3]
[4]
8
[5]
vertices
V0
V1
V2
V3
V4
V5
predecessors
V0
V0
distance
10
17
vertices
V0
V1
V2
V3
V4
V5
V0
V1
V1
predecessors
V1
distance
10
17
11
vertices
V0
V1
V2
V3
V4
V5
V0
V1
V1
V5
V1
predecessors
distance
10
11
11
vertices
V0
V1
V2
V3
V4
V5
V0
V1
V2
V5
V1
predecessors
Adding V0 and V1 does not change the distance array, and therefore, a predecessor array.
distance
10
11
11
vertices
V0
V1
V2
V3
V4
V5
V0
V1
V2
V5
V1
predecessors
V0 V1 V2 V3 .
Indeed, if we add the weights that labeled the arrows and sum it up, we can see the result
coincides with the data in the distance array.
V0 V1 V2 V3
2
Now we are ready to write a code an to provide Complexity Analysis for Dijkstra
Algorithm.