0% found this document useful (0 votes)
39 views

Dijkstra Algorithm

The document discusses Dijkstra's algorithm for finding the shortest paths between a source node and all other nodes in a graph. It begins by explaining how the closest, second closest, and third closest nodes are determined. It then outlines the steps of the algorithm, which are to initialize by setting the source node distance to 0 and all other distances to infinity, then repeatedly select the closest unvisited node and update neighboring nodes' distances until all nodes have been visited. An example execution of the algorithm on a sample graph is provided to demonstrate how the distances are updated on each iteration.

Uploaded by

Aryaman Mishra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Dijkstra Algorithm

The document discusses Dijkstra's algorithm for finding the shortest paths between a source node and all other nodes in a graph. It begins by explaining how the closest, second closest, and third closest nodes are determined. It then outlines the steps of the algorithm, which are to initialize by setting the source node distance to 0 and all other distances to infinity, then repeatedly select the closest unvisited node and update neighboring nodes' distances until all nodes have been visited. An example execution of the algorithm on a sample graph is provided to demonstrate how the distances are updated on each iteration.

Uploaded by

Aryaman Mishra
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Dijkstra AIgorithm: Finding

shortest paths in order


.
.
.
.
Closest node to . is 1 hop away
.
_
_
2
nd
closest node to . is 1 hop
away from . or ."
_
:
:
3rd closest node to . is 1 hop
away from ., .", or _
.
Find shortest paths from
source s to all other
destinations
Dijkstra's aIgorithm
N set of nodes for which shortest path already found
nitialization (Start with source node s)
N = {s}, D
s
0, "s is distance zero from itself
D
j
=C
sj
for all j s, distances of directly-connected neighbors
Step A (ind next closest node i
Find i [ N such that
D
i
min Dj for j [ N
Add i to N
f N contains all the nodes, stop
Step B (update minimum costs)
For each node j [ N
D
j
min (D
j
, D
i
+C
ij

o to Step A
inimum distance from s to
j through node in N
ecution of Dijkstra's aIgorithm
teration N D
2
D
3
D
4
D
5
D
6
nitial {1} 3 2 5 M M
1 {1,3} 3 4 M 3
2 {1,2,3} 4 7 3
3 {1,2,3,6} 4 5
4 {1,2,3,4,6} 5
5 {1,2,3,4,5,6}

$hortest Paths in Dijkstra's


AIgorithm

You might also like