Dijkstra’s Algorithm
We consider a weighted connected simple graph G with vertices a = v0, v1, . . . , vn = z and
weights w(vi, vj) > 0 where w(vi, vj) = ∞ if {vi, vj} is not an edge. Dijkstra’s algorithm finds
the cost of the “cheapest” path between vertices a and z.
procedure Dijkstra(G: weighted connected simple graph, with all weights positive)
for i = 1 to n
L(vi) := ∞
L(a) := 0
S := ∅
while z ∈ S
begin
u := a vertex not in S with L(u) minimal
S := S ∪ {u}
for all vertices v ∈ S
if L(u) + w(u, v) < L(v) then L(v) := L(u) + w(u, v)
end
return(L(z))
Example: Use Dijkstra’s algorithm to find the cost of the cheapest path between a and z in
the following weighted graph. Describe at each iteration the function L and set S.
r.
....................................................................................................................................................................................................
r
.
....................................................................................................................................................................................................
r. ............................................................................................................................................................................................................................................................ r
. ............................................................................................................................................................................................................................................................ r.
....................................................................................................................................................................................................
r
.
.....................................................................................................................................................................................................
........................................................................................................................................................................
.
...................................................................................................................................................................................................................................................................................................................
.
........................................................................................................................................................................
a z
c e
b d
3 4
3
1
2 2
5
16
Solution: The iterations of Dijkstra’s algorithm are described in the following table.
S L(a) L(b) L(c) L(d) L(e) L(z)
∅ 0 ∞ ∞ ∞ ∞ ∞
{a} 2 3 ∞ ∞ ∞
{a, b} 3 7 5 ∞
{a, b, c} 7 4 ∞
{a, b, c, e} 5 8
{a, b, c, e, d} 7
{a, b, c, e, d, z}
At the last iteration, z ∈ S and L(z) = 7. We conclude that the cheapest path from a to z has
a cost of 7.
Gilles Cazelais. Typeset with LATEX on December 2, 2006.

More Related Content

PPTX
Vectors space definition with axiom classification
PPTX
Integration
PPT
lecture 21
PPT
lecture 22
PPTX
Greedy Algorithm-Dijkstra's algo
PPTX
Quaternion to axis
PDF
Dynamics Kinematics Curvilinear Motion
PDF
8th alg -l1.6
Vectors space definition with axiom classification
Integration
lecture 21
lecture 22
Greedy Algorithm-Dijkstra's algo
Quaternion to axis
Dynamics Kinematics Curvilinear Motion
8th alg -l1.6

What's hot (20)

PPT
Algorithm Design and Complexity - Course 9
PPTX
VECTOR FUNCTION
PPTX
Vectorspace in 2,3and n space
PPTX
vector application
PPTX
Prims and kruskal algorithms
PDF
JRS at Event Synchronization Task
PDF
A non-stiff boundary integral method for internal waves
PPT
Interpreting Free Body Diagrams
PPT
Interpreting Free Body Diagrams
PPTX
Verification of Solenoidal & Irrotational
PPT
Integration by parts
PPTX
Minimum spanning tree algorithms by ibrahim_alfayoumi
PDF
Single source shortes path in dag
PDF
Longest common subsequence
DOCX
B.tech ii unit-4 material vector differentiation
PDF
On Uq(sl2)-actions on the quantum plane
PPTX
Prims & kruskal algorithms
PPTX
14 formulas from integration by parts x
Algorithm Design and Complexity - Course 9
VECTOR FUNCTION
Vectorspace in 2,3and n space
vector application
Prims and kruskal algorithms
JRS at Event Synchronization Task
A non-stiff boundary integral method for internal waves
Interpreting Free Body Diagrams
Interpreting Free Body Diagrams
Verification of Solenoidal & Irrotational
Integration by parts
Minimum spanning tree algorithms by ibrahim_alfayoumi
Single source shortes path in dag
Longest common subsequence
B.tech ii unit-4 material vector differentiation
On Uq(sl2)-actions on the quantum plane
Prims & kruskal algorithms
14 formulas from integration by parts x
Ad

Similar to Dijkstra algorithm (20)

PPT
lecture2faafffffffffffffffaaaaaaaaaaa4.ppt
PDF
Lecture 16 - Dijkstra's Algorithm.pdf
PPT
Unit26 shortest pathalgorithm
PPTX
Dijkstra's algorithm presentation
PDF
Dijkstra algorithm
PPT
Dijkstra Shortest Path Algorithm in Network.ppt
PPT
Dijkstra algorithm ds 57612334t4t44.ppt
PPTX
Algo labpresentation a_group
PPT
Dijkstra.ppt
PDF
Djikstra’s Algorithm. Approach to shortest path algorithm with greedy method
PPTX
dms slide discrete mathematics sem 2 engineering
PPTX
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
PPT
Dijesktra 1.ppt
PPTX
Shortest-Path Problems - Graph Theory in Computer Applications
PPT
Single source stortest path bellman ford and dijkstra
PPT
graph in Data Structures and Algorithm.ppt
PPTX
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
PPT
dijkstra algo.ppt
PDF
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
PPT
2.6 all pairsshortestpath
lecture2faafffffffffffffffaaaaaaaaaaa4.ppt
Lecture 16 - Dijkstra's Algorithm.pdf
Unit26 shortest pathalgorithm
Dijkstra's algorithm presentation
Dijkstra algorithm
Dijkstra Shortest Path Algorithm in Network.ppt
Dijkstra algorithm ds 57612334t4t44.ppt
Algo labpresentation a_group
Dijkstra.ppt
Djikstra’s Algorithm. Approach to shortest path algorithm with greedy method
dms slide discrete mathematics sem 2 engineering
SEMINAR ON SHORTEST PATH ALGORITHMS.pptx
Dijesktra 1.ppt
Shortest-Path Problems - Graph Theory in Computer Applications
Single source stortest path bellman ford and dijkstra
graph in Data Structures and Algorithm.ppt
Dijkstra Algorithm Presentation -the shortest path finding algorithm.pptx
dijkstra algo.ppt
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
2.6 all pairsshortestpath
Ad

More from rishi ram khanal (20)

PPTX
Measurement of gdp under product method
PPTX
Major social problem in nepal child labour socilology
PPTX
Light source ooad
PPTX
Introduction to java
PPTX
Introduction to artificial intelligence
PPTX
Interview method in research
PPTX
Presentation on kurtosis statistics
PPTX
Importance of double entry accounting system for public limited company (basi...
PPTX
Implementation issues software engineering
PPTX
Effect of migration in developing country
PPTX
GUI (graphical user interface)
PPTX
Goals of firm business finance
PPTX
General register organization (computer organization)
PPTX
GDP and trends economics .rishi
PDF
Final internship-report on the networking department of the internet service ...
PPTX
Field study of crystal finance share broker
PPTX
Computer virus and worms
PPTX
Database management system
PPTX
Credential reuse cyber security
DOCX
Cisco packet tracer router
Measurement of gdp under product method
Major social problem in nepal child labour socilology
Light source ooad
Introduction to java
Introduction to artificial intelligence
Interview method in research
Presentation on kurtosis statistics
Importance of double entry accounting system for public limited company (basi...
Implementation issues software engineering
Effect of migration in developing country
GUI (graphical user interface)
Goals of firm business finance
General register organization (computer organization)
GDP and trends economics .rishi
Final internship-report on the networking department of the internet service ...
Field study of crystal finance share broker
Computer virus and worms
Database management system
Credential reuse cyber security
Cisco packet tracer router

Recently uploaded (20)

PPTX
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
PPTX
Software-Development-Life-Cycle-SDLC.pptx
PPTX
CS6006 - CLOUD COMPUTING - Module - 1.pptx
PDF
IAE-V2500 Engine Airbus Family A319/320
PDF
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
PDF
V2500 Owner and Operatore Guide for Airbus
PPTX
Real Estate Management PART 1.pptxFFFFFFFFFFFFF
PPT
UNIT-I Machine Learning Essentials for 2nd years
PDF
ST MNCWANGO P2 WIL (MEPR302) FINAL REPORT.pdf
PDF
Cryptography and Network Security-Module-I.pdf
DOCX
An investigation of the use of recycled crumb rubber as a partial replacement...
PPTX
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
PPTX
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
PPTX
DATA STRCUTURE LABORATORY -BCSL305(PRG1)
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
PDF
Mechanics of materials week 2 rajeshwari
PDF
Software defined netwoks is useful to learn NFV and virtual Lans
PDF
Research on ultrasonic sensor for TTU.pdf
PDF
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
PPTX
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS
BBOC407 BIOLOGY FOR ENGINEERS (CS) - MODULE 1 PART 1.pptx
Software-Development-Life-Cycle-SDLC.pptx
CS6006 - CLOUD COMPUTING - Module - 1.pptx
IAE-V2500 Engine Airbus Family A319/320
MACCAFERRY GUIA GAVIONES TERRAPLENES EN ESPAÑOL
V2500 Owner and Operatore Guide for Airbus
Real Estate Management PART 1.pptxFFFFFFFFFFFFF
UNIT-I Machine Learning Essentials for 2nd years
ST MNCWANGO P2 WIL (MEPR302) FINAL REPORT.pdf
Cryptography and Network Security-Module-I.pdf
An investigation of the use of recycled crumb rubber as a partial replacement...
WN UNIT-II CH4_MKaruna_BapatlaEngineeringCollege.pptx
INTERNET OF THINGS - EMBEDDED SYSTEMS AND INTERNET OF THINGS
DATA STRCUTURE LABORATORY -BCSL305(PRG1)
Principles of operation, construction, theory, advantages and disadvantages, ...
Mechanics of materials week 2 rajeshwari
Software defined netwoks is useful to learn NFV and virtual Lans
Research on ultrasonic sensor for TTU.pdf
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
ARCHITECTURE AND PROGRAMMING OF EMBEDDED SYSTEMS

Dijkstra algorithm

  • 1. Dijkstra’s Algorithm We consider a weighted connected simple graph G with vertices a = v0, v1, . . . , vn = z and weights w(vi, vj) > 0 where w(vi, vj) = ∞ if {vi, vj} is not an edge. Dijkstra’s algorithm finds the cost of the “cheapest” path between vertices a and z. procedure Dijkstra(G: weighted connected simple graph, with all weights positive) for i = 1 to n L(vi) := ∞ L(a) := 0 S := ∅ while z ∈ S begin u := a vertex not in S with L(u) minimal S := S ∪ {u} for all vertices v ∈ S if L(u) + w(u, v) < L(v) then L(v) := L(u) + w(u, v) end return(L(z)) Example: Use Dijkstra’s algorithm to find the cost of the cheapest path between a and z in the following weighted graph. Describe at each iteration the function L and set S. r. .................................................................................................................................................................................................... r . .................................................................................................................................................................................................... r. ............................................................................................................................................................................................................................................................ r . ............................................................................................................................................................................................................................................................ r. .................................................................................................................................................................................................... r . ..................................................................................................................................................................................................... ........................................................................................................................................................................ . ................................................................................................................................................................................................................................................................................................................... . ........................................................................................................................................................................ a z c e b d 3 4 3 1 2 2 5 16 Solution: The iterations of Dijkstra’s algorithm are described in the following table. S L(a) L(b) L(c) L(d) L(e) L(z) ∅ 0 ∞ ∞ ∞ ∞ ∞ {a} 2 3 ∞ ∞ ∞ {a, b} 3 7 5 ∞ {a, b, c} 7 4 ∞ {a, b, c, e} 5 8 {a, b, c, e, d} 7 {a, b, c, e, d, z} At the last iteration, z ∈ S and L(z) = 7. We conclude that the cheapest path from a to z has a cost of 7. Gilles Cazelais. Typeset with LATEX on December 2, 2006.