0% found this document useful (0 votes)
22 views11 pages

UNIT-IV Lect-6

Uploaded by

nakhatebhavana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views11 pages

UNIT-IV Lect-6

Uploaded by

nakhatebhavana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

MIT Art Design and Technology University

MIT School of Computing, Pune


Department of ASH (Mathematics)

Mathematical Foundation for Computing-I

Class - F.Y. (SEM-I)

Unit - IV Graph Theory

AY 2024-2025 SEM-I
Lecture-06-: Dijkstra’s Algorithm
• Contents
• Introduction
• Dijkstra’s Algorithm
• Applications
• Methods
• Examples
• Home Assignment
Dijkstra’s Algorithm
• The algorithm was developed by a Dutch computer scientist
Edsger W. Dijkstra in 1956.
• It is used to find the shortest path between a node/vertex
(source node) to any (or every) other nodes/vertices (destination
nodes) in a graph.
• This algorithm is sometimes referred to as Single Source Shortest
Path Algorithm (SSSPA) due to its nature of implementation.
Application
• It is most widely used in finding shortest possible distance and
show directions between 2 geographical locations such as in
Google Maps.
• This is also widely used in routing of data in networking and
telecommunication domains for minimizing the delay occurred for
transmission.
• Wherever you encounter the need for shortest path solutions be
it in robotics, transportation, embedded systems, factory or
production plants to detect faults, etc this algorithm is used.
Working of Dijkstra's Shortest Path First Algorithm
• Dijkstra’s algorithm mainly allocates a “cost” value taken to reach the
destination vertex from the source vertex. The “cost” can be mapped to
distance, money or time taken to reach from source to a destination.
• Convert any problem to its graph equivalent representation.
• Maintain a list of unvisited vertices. Assign a vertex as “source” and
also allocate a maximum possible cost (infinity) to every other vertex.
The cost of the source to itself will be zero as it actually takes nothing to
go to itself.
• In every step of the algorithm, it tries to minimize the cost for each
vertex.
• For every unvisited neighbors of the current vertex () calculate the new
• The new cost of is calculated as :

• When all the neighbors of the current node are visited and cost
has been calculated, mark the current node as visited and
remove it from the unvisited list.
• Select next vertex with smallest cost from the unvisited list and
repeat.
• The algorithm finally ends when there are no unvisited nodes left.
• Dijkstra’s Algorithm can also be used for directed graphs as well.
• The shortest path might not pass through all the vertices. Also,
there can be more than one shortest path between two nodes.
• Dijkstra’s Algorithm doesn't work for graphs with negative edges.
• Animated Examples can be seen in the following link:
• Dijkstra Visualzation (usfca.edu)
Example 2:
Example 1: Use Dijkstra’s algorithm to find the shortest path
between A and Z in the following figures.

a b c d e z
Step 1: 2 3
Step 2: 3
Step 3: 3
Step 4: 3 2
Step 5: 3
The shortest Path is .
The shortest distance is = 2 + 2 + 1 + 2 = 7
Example 2: Use Dijkstra’s algorithm to find the shortest path
between A and Z in the following figures.
a b c d e f g z
Step 1: 2 4 5
Step 2: 1
Step 3: 1 7
Step 4: 1 7
Step 5: 1 7
Step 6: 1 1
Step 6: 1
The shortest Path is . The shortest distance is = 2 + 1 + 1 + 2 + 1 = 7
Thank you

You might also like