SlideShare a Scribd company logo
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.
Ad

More Related Content

What's hot (20)

Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9
Traian Rebedea
 
VECTOR FUNCTION
VECTOR FUNCTION VECTOR FUNCTION
VECTOR FUNCTION
Siddhi Shrivas
 
Vectorspace in 2,3and n space
Vectorspace in 2,3and n spaceVectorspace in 2,3and n space
Vectorspace in 2,3and n space
Ahmad Saifullah
 
vector application
vector applicationvector application
vector application
rajat shukla
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
Saga Valsalan
 
JRS at Event Synchronization Task
JRS at Event Synchronization TaskJRS at Event Synchronization Task
JRS at Event Synchronization Task
multimediaeval
 
A non-stiff boundary integral method for internal waves
A non-stiff boundary integral method for internal wavesA non-stiff boundary integral method for internal waves
A non-stiff boundary integral method for internal waves
Alex (Oleksiy) Varfolomiyev
 
Interpreting Free Body Diagrams
Interpreting Free Body DiagramsInterpreting Free Body Diagrams
Interpreting Free Body Diagrams
Calvert County Public Schools
 
Interpreting Free Body Diagrams
Interpreting Free Body DiagramsInterpreting Free Body Diagrams
Interpreting Free Body Diagrams
Calvert County Public Schools
 
Verification of Solenoidal & Irrotational
Verification of Solenoidal & IrrotationalVerification of Solenoidal & Irrotational
Verification of Solenoidal & Irrotational
MdAlAmin187
 
Vector Spaces
Vector SpacesVector Spaces
Vector Spaces
Franklin College Mathematics and Computing Department
 
Integration by parts
Integration by partsIntegration by parts
Integration by parts
Елена Доброштан
 
Minimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumiMinimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumi
Ibrahim Alfayoumi
 
Single source shortes path in dag
Single source shortes path in dagSingle source shortes path in dag
Single source shortes path in dag
Kiran K
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequence
Kiran K
 
Sol23
Sol23Sol23
Sol23
eli priyatna laidan
 
B.tech ii unit-4 material vector differentiation
B.tech ii unit-4 material vector differentiationB.tech ii unit-4 material vector differentiation
B.tech ii unit-4 material vector differentiation
Rai University
 
On Uq(sl2)-actions on the quantum plane
On Uq(sl2)-actions on the quantum planeOn Uq(sl2)-actions on the quantum plane
On Uq(sl2)-actions on the quantum plane
Steven Duplij (Stepan Douplii)
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithms
Ayesha Tahir
 
14 formulas from integration by parts x
14 formulas from integration by parts x14 formulas from integration by parts x
14 formulas from integration by parts x
math266
 
Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9Algorithm Design and Complexity - Course 9
Algorithm Design and Complexity - Course 9
Traian Rebedea
 
Vectorspace in 2,3and n space
Vectorspace in 2,3and n spaceVectorspace in 2,3and n space
Vectorspace in 2,3and n space
Ahmad Saifullah
 
vector application
vector applicationvector application
vector application
rajat shukla
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
Saga Valsalan
 
JRS at Event Synchronization Task
JRS at Event Synchronization TaskJRS at Event Synchronization Task
JRS at Event Synchronization Task
multimediaeval
 
A non-stiff boundary integral method for internal waves
A non-stiff boundary integral method for internal wavesA non-stiff boundary integral method for internal waves
A non-stiff boundary integral method for internal waves
Alex (Oleksiy) Varfolomiyev
 
Verification of Solenoidal & Irrotational
Verification of Solenoidal & IrrotationalVerification of Solenoidal & Irrotational
Verification of Solenoidal & Irrotational
MdAlAmin187
 
Minimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumiMinimum spanning tree algorithms by ibrahim_alfayoumi
Minimum spanning tree algorithms by ibrahim_alfayoumi
Ibrahim Alfayoumi
 
Single source shortes path in dag
Single source shortes path in dagSingle source shortes path in dag
Single source shortes path in dag
Kiran K
 
Longest common subsequence
Longest common subsequenceLongest common subsequence
Longest common subsequence
Kiran K
 
B.tech ii unit-4 material vector differentiation
B.tech ii unit-4 material vector differentiationB.tech ii unit-4 material vector differentiation
B.tech ii unit-4 material vector differentiation
Rai University
 
Prims & kruskal algorithms
Prims & kruskal algorithmsPrims & kruskal algorithms
Prims & kruskal algorithms
Ayesha Tahir
 
14 formulas from integration by parts x
14 formulas from integration by parts x14 formulas from integration by parts x
14 formulas from integration by parts x
math266
 

Similar to Dijkstra algorithm (20)

Lec-35Graph - Graph - Copy in Data Structure
Lec-35Graph - Graph - Copy in Data StructureLec-35Graph - Graph - Copy in Data Structure
Lec-35Graph - Graph - Copy in Data Structure
Anil Yadav
 
Dijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.pptDijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.ppt
RAJASEKARAN G
 
Dijkstra algorithm ds 57612334t4t44.ppt
Dijkstra algorithm  ds 57612334t4t44.pptDijkstra algorithm  ds 57612334t4t44.ppt
Dijkstra algorithm ds 57612334t4t44.ppt
ssuser7b9bda1
 
Dijksatra
DijksatraDijksatra
Dijksatra
Tanmay Baranwal
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 
Dijkstra's algorithm for computer science
Dijkstra's algorithm for computer scienceDijkstra's algorithm for computer science
Dijkstra's algorithm for computer science
ajmalnajath4
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
Ruchika Sinha
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
Single Source Shortest Path Algorithm.ppt
Single Source Shortest Path Algorithm.pptSingle Source Shortest Path Algorithm.ppt
Single Source Shortest Path Algorithm.ppt
RAJASEKARAN G
 
Dijkstra c
Dijkstra cDijkstra c
Dijkstra c
shrikant00786
 
Weighted graphs
Weighted graphsWeighted graphs
Weighted graphs
Core Condor
 
Dijkstras single source path algorthim
Dijkstras   single source path algorthimDijkstras   single source path algorthim
Dijkstras single source path algorthim
Bobby Pra A
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
Krish_ver2
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
Ruchika Sinha
 
04 greedyalgorithmsii
04 greedyalgorithmsii04 greedyalgorithmsii
04 greedyalgorithmsii
LENIN Quintero
 
graph in Data Structures and Algorithm.ppt
graph in Data Structures and Algorithm.pptgraph in Data Structures and Algorithm.ppt
graph in Data Structures and Algorithm.ppt
RAJASEKARAN G
 
Bellman ford
Bellman fordBellman ford
Bellman ford
Kiran K
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part III
Wongyos Keardsri
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
Rashik Ishrak Nahian
 
Graph theory
Graph theoryGraph theory
Graph theory
Jeane Paguio
 
Lec-35Graph - Graph - Copy in Data Structure
Lec-35Graph - Graph - Copy in Data StructureLec-35Graph - Graph - Copy in Data Structure
Lec-35Graph - Graph - Copy in Data Structure
Anil Yadav
 
Dijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.pptDijkstra Shortest Path Algorithm in Network.ppt
Dijkstra Shortest Path Algorithm in Network.ppt
RAJASEKARAN G
 
Dijkstra algorithm ds 57612334t4t44.ppt
Dijkstra algorithm  ds 57612334t4t44.pptDijkstra algorithm  ds 57612334t4t44.ppt
Dijkstra algorithm ds 57612334t4t44.ppt
ssuser7b9bda1
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 
Dijkstra's algorithm for computer science
Dijkstra's algorithm for computer scienceDijkstra's algorithm for computer science
Dijkstra's algorithm for computer science
ajmalnajath4
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
Ruchika Sinha
 
Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10Algorithm Design and Complexity - Course 10
Algorithm Design and Complexity - Course 10
Traian Rebedea
 
Single Source Shortest Path Algorithm.ppt
Single Source Shortest Path Algorithm.pptSingle Source Shortest Path Algorithm.ppt
Single Source Shortest Path Algorithm.ppt
RAJASEKARAN G
 
Dijkstras single source path algorthim
Dijkstras   single source path algorthimDijkstras   single source path algorthim
Dijkstras single source path algorthim
Bobby Pra A
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
Krish_ver2
 
graph in Data Structures and Algorithm.ppt
graph in Data Structures and Algorithm.pptgraph in Data Structures and Algorithm.ppt
graph in Data Structures and Algorithm.ppt
RAJASEKARAN G
 
Bellman ford
Bellman fordBellman ford
Bellman ford
Kiran K
 
Discrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part IIIDiscrete-Chapter 11 Graphs Part III
Discrete-Chapter 11 Graphs Part III
Wongyos Keardsri
 
Ad

More from rishi ram khanal (20)

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

Recently uploaded (20)

Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation RateModeling the Influence of Environmental Factors on Concrete Evaporation Rate
Modeling the Influence of Environmental Factors on Concrete Evaporation Rate
Journal of Soft Computing in Civil Engineering
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning ModelsMode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Mode-Wise Corridor Level Travel-Time Estimation Using Machine Learning Models
Journal of Soft Computing in Civil Engineering
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control Monthly May 2025
Water Industry Process Automation & Control
 
Nanometer Metal-Organic-Framework Literature Comparison
Nanometer Metal-Organic-Framework  Literature ComparisonNanometer Metal-Organic-Framework  Literature Comparison
Nanometer Metal-Organic-Framework Literature Comparison
Chris Harding
 
Generative AI & Large Language Models Agents
Generative AI & Large Language Models AgentsGenerative AI & Large Language Models Agents
Generative AI & Large Language Models Agents
aasgharbee22seecs
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Autodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User InterfaceAutodesk Fusion 2025 Tutorial: User Interface
Autodesk Fusion 2025 Tutorial: User Interface
Atif Razi
 
Evonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdfEvonik Overview Visiomer Specialty Methacrylates.pdf
Evonik Overview Visiomer Specialty Methacrylates.pdf
szhang13
 
SICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introductionSICPA: Fabien Keller - background introduction
SICPA: Fabien Keller - background introduction
fabienklr
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
Uses of drones in civil construction.pdf
Uses of drones in civil construction.pdfUses of drones in civil construction.pdf
Uses of drones in civil construction.pdf
surajsen1729
 

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.
  翻译: