PUNDRA UNIVERSITY OF
SCIENCE & TECHNOLOGY
PRESENTATION ON:
DIJSKTRA’S SORTEST PATH ALGORITHM
1
Name: Md.Delowar
Hossain Dolon
ID: 00817206031
Batch: 2nd
Semester: 6th
Department of CSE
Name: Mst. Rehena
Khatun
Designation: Lecturer in
CSE
Department of CSE
Submitted By Submitted To
DIJKSTRA'S ALGORITHM
 Dijkstra's algorithm: finds shortest
(minimum weight) path between a particular pair of
vertices in a weighted directed graph with nonnegative
edge weights
2
EXAMPLE:
3
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 ∞
∞ ∞
∞
Pick vertex in List with minimum distance.
∞ ∞
Distance(source) = 0 Distance (all vertices
but source) = ∞
EXAMPLE: UPDATE NEIGHBORS'
DISTANCE
4
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
∞ ∞
1
∞ ∞
Distance(B) = 2
Distance(D) = 1
REMOVE VERTEX WITH MINIMUM
DISTANCE
5Pick vertex in List with minimum distance, i.e., D
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
∞ ∞
1
∞ ∞
UPDATE NEIGHBORS
6
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
9 5
Distance(C) = 1 + 2 = 3
Distance(E) = 1 + 2 = 3
Distance(F) = 1 + 8 = 9
Distance(G) = 1 + 4 = 5
EXAMPLE: CONTINUED...
7
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
Pick vertex in List with minimum distance (B) and update neighbors
9 5
Note : distance(D) not
updated since D is
already known and
distance(E) not
updated since it is
larger than previously
computed
EXAMPLE: CONTINUE...
8
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
9 5
No updating
Pick vertex List with minimum distance (E) and update neighbors
EXAMPLE: CONTINUED...
9
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
8 5
Pick vertex List with minimum distance (C) and update neighbors
Distance(F) = 3 + 5 = 8
EXAMPLE: CONTINUED...
10
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
6 5
Distance(F) = min (8, 5+1) = 6
Previous distance
Pick vertex List with minimum distance (G) and update neighbors
EXAMPLE (END)
11
A
GF
B
EC D
4 1
2
103
64
22
85
1
0 2
3 3
1
Pick vertex not in S with lowest cost (F) and update neighbors
6 5
DIJKSTRA'S EXERCISE
 Use Dijkstra's algorithm to determine the lowest cost path from
vertex A to all of the other vertices in the graph. Keep track of
previous vertices so that you can reconstruct the path later.
12
A
G
F
B
E
C
D
20
10
50
40
20
80
50
20
30
20
90
H
10
10
10
.
13

Dijsktra’s Sortest path algorithm

  • 1.
    PUNDRA UNIVERSITY OF SCIENCE& TECHNOLOGY PRESENTATION ON: DIJSKTRA’S SORTEST PATH ALGORITHM 1 Name: Md.Delowar Hossain Dolon ID: 00817206031 Batch: 2nd Semester: 6th Department of CSE Name: Mst. Rehena Khatun Designation: Lecturer in CSE Department of CSE Submitted By Submitted To
  • 2.
    DIJKSTRA'S ALGORITHM  Dijkstra'salgorithm: finds shortest (minimum weight) path between a particular pair of vertices in a weighted directed graph with nonnegative edge weights 2
  • 3.
    EXAMPLE: 3 A GF B EC D 4 1 2 103 64 22 85 1 0∞ ∞ ∞ ∞ Pick vertex in List with minimum distance. ∞ ∞ Distance(source) = 0 Distance (all vertices but source) = ∞
  • 4.
    EXAMPLE: UPDATE NEIGHBORS' DISTANCE 4 A GF B ECD 4 1 2 103 64 22 85 1 0 2 ∞ ∞ 1 ∞ ∞ Distance(B) = 2 Distance(D) = 1
  • 5.
    REMOVE VERTEX WITHMINIMUM DISTANCE 5Pick vertex in List with minimum distance, i.e., D A GF B EC D 4 1 2 103 64 22 85 1 0 2 ∞ ∞ 1 ∞ ∞
  • 6.
    UPDATE NEIGHBORS 6 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 9 5 Distance(C) = 1 + 2 = 3 Distance(E) = 1 + 2 = 3 Distance(F) = 1 + 8 = 9 Distance(G) = 1 + 4 = 5
  • 7.
    EXAMPLE: CONTINUED... 7 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 Pick vertex in List with minimum distance (B) and update neighbors 9 5 Note : distance(D) not updated since D is already known and distance(E) not updated since it is larger than previously computed
  • 8.
    EXAMPLE: CONTINUE... 8 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 9 5 No updating Pick vertex List with minimum distance (E) and update neighbors
  • 9.
    EXAMPLE: CONTINUED... 9 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 8 5 Pick vertex List with minimum distance (C) and update neighbors Distance(F) = 3 + 5 = 8
  • 10.
    EXAMPLE: CONTINUED... 10 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 6 5 Distance(F) = min (8, 5+1) = 6 Previous distance Pick vertex List with minimum distance (G) and update neighbors
  • 11.
    EXAMPLE (END) 11 A GF B EC D 41 2 103 64 22 85 1 0 2 3 3 1 Pick vertex not in S with lowest cost (F) and update neighbors 6 5
  • 12.
    DIJKSTRA'S EXERCISE  UseDijkstra's algorithm to determine the lowest cost path from vertex A to all of the other vertices in the graph. Keep track of previous vertices so that you can reconstruct the path later. 12 A G F B E C D 20 10 50 40 20 80 50 20 30 20 90 H 10 10 10
  • 13.