SlideShare uma empresa Scribd logo
1 de 15
DIJKSTRA'S ALGORITHM,
BY
DR HJH RAHMAH BT MURSHIDI
INTRODUCTION
 Dijkstra's algorithm, named after its
discoverer, Dutch computer scientist Edsger
Dijkstra
 A greedy algorithm that solves the single-source
shortest path problem for a directed graph with
non negative edge weights.
INTRODUCTION
 For example, if the vertices of the graph
represent cities and edge weights represent
driving distances between pairs of cities
connected by a direct road, Dijkstra's algorithm
can be used to find the shortest route between
two cities.
 The input of the algorithm consists of a weighted
directed graph G and a source vertex s in G
 Denote V as the set of all vertices in the graph G.
 Each edge of the graph is an ordered pair of
vertices (u,v)
 This representings a connection from vertex u to
vertex v
 The set of all edges is denoted E
 Weights of edges are given by a weight function
w: E → [0, ∞)
 Therefore w(u,v) is the cost of moving directly
from vertex u to vertex v
 The cost of an edge can be thought of as (a
generalization of) the distance between those
two vertices
 The cost of a path between two vertices is the
sum of costs of the edges in that path
 For a given pair of vertices s and t in V, the
algorithm finds the path from s to t with lowest
cost (i.e. the shortest path)
 It can also be used for finding costs of shortest
paths from a single vertex s to all other vertices
in the graph.
BOXES AT EACH NODE
Order of
labelling
Label (i.e
Permanent
label)
Working
values
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM FROM S TO T
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 1
Label start node S
with permanent label
(P-label) of 0.
1 0
4
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
4
3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 2
For all nodes that
can be reached
directly from S,
assign temporary
labels (T-labels)
equal to their direct
distance from S
6
4
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
4
2 3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 3
Select the node with
smallest T label and
makes its label
permanent. In this
case the node is A.
The P-label
represents the
shortest distance
from S to that node.
Put the order of
labeling as 2.
6
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
4
2 3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 4
Consider all nodes
that can be reached
from A, that are B
and T. Shortest
route from S to B via
A is 3+4 =7, but B is
already labelled as 6
and it’s the best so
far. The shortest
route from S to T via
A is 3 + 11 = 14. Put
T-label as 14 in T
6
4
14
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
3 4
2 3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 5
Compare node T, B
and C. The smallest
T label is now 4 at C.
Since this value
cannot be improved,
it becomes P-label of
4. Put the order of
labeling at C as 3
6
4
14
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
3 4
2 3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 6
Consider all nodes that
can be reached from C,
that are B and D.
Shortest route from S to B
via C is 4+1 =5 which is
shorter than 6. Change T
label 6 to P label 5. The
shortest route from S to D
via C is 4 + 4 = 8. Put T-
label as 8 in D. Compare
B and D. B is less than D,
so the next node is B. Put
the order of labeling at B
as 4
4 5
4
14
8
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
3 4
4
2 3
3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 7
Consider all nodes that
can be reached from B;
that are D and T.
Shortest route from S to
D via B is 5+2 =7 which
is shorter than 8. Change
T label 8 to P label 7. The
shortest route from S to T
via B is 5 + 8 = 13. This is
smaller than 14 so
change to 13 in T as T
label. Compare T and D.
D is less than T so chose
D as the next node. Put
the order of labeling as 5
in D
4 5
6,5
4
6 13
14,13
5 7
8,7
TO FIND THE SHORTEST ROUTE BY
DIJKSTRA’S ALGORITHM
3 4
4
2 3
3
1 0
S
A
B
T
D
C
3
11
5
8
6
4
1
2
4
Step 8
The last node is T. Put the
order of labeling as 6 in T.
Compare the routes from
S to T via A (3 + 11 =14),
via B ( 5 + 8 =13) and via
D (7 + 5 =12). It seems
that the shortest route
from S to T is via D.
Change the T label in T
(13) to P label with the
value 12. Therefore the
shortest way from S to T
is SCBDT which is 12
4 5
6,5
4
6 12
14,13,12
5 7
8,7

Mais conteúdo relacionado

Mais procurados (20)

Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Dijkstra
DijkstraDijkstra
Dijkstra
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
dijkstra algo.ppt
dijkstra algo.pptdijkstra algo.ppt
dijkstra algo.ppt
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 
Dijkstra algorithm
Dijkstra algorithmDijkstra algorithm
Dijkstra algorithm
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Topological sort
Topological sortTopological sort
Topological sort
 
Bfs and Dfs
Bfs and DfsBfs and Dfs
Bfs and Dfs
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Graph theory
Graph theoryGraph theory
Graph theory
 
Bfs dfs
Bfs dfsBfs dfs
Bfs dfs
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Shortest path
Shortest pathShortest path
Shortest path
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 

Destaque

Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraOnggo Wiryawan
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithmPulkit Goel
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Anshul gour
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithmSrikrishnan Suresh
 
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...Waqas Tariq
 
Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibMarc Gouw
 
Quantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraQuantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraadarsh
 
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla LacovinoLife after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla LacovinoPyData
 
Path cycle part1
Path cycle part1Path cycle part1
Path cycle part1guestb63941
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Wen-Wei Liao
 
Dijkstra's Algorithm - Colleen Young
Dijkstra's Algorithm  - Colleen YoungDijkstra's Algorithm  - Colleen Young
Dijkstra's Algorithm - Colleen YoungColleen Young
 
History Of Linux
History Of LinuxHistory Of Linux
History Of Linuxanand09
 
Operating Systems: A History of Linux
Operating Systems: A History of LinuxOperating Systems: A History of Linux
Operating Systems: A History of LinuxDamian T. Gordon
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to AlgorithmsVenkatesh Iyer
 

Destaque (20)

Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithm
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)
 
All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...
Dynamic Role Engine and Formation Control for Cooperating Agents with Robust ...
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
 
Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
 
Quantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraQuantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstra
 
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla LacovinoLife after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
 
Path cycle part1
Path cycle part1Path cycle part1
Path cycle part1
 
Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012Use the Matplotlib, Luke @ PyCon Taiwan 2012
Use the Matplotlib, Luke @ PyCon Taiwan 2012
 
Dijksatra
DijksatraDijksatra
Dijksatra
 
Dijkstra's Algorithm - Colleen Young
Dijkstra's Algorithm  - Colleen YoungDijkstra's Algorithm  - Colleen Young
Dijkstra's Algorithm - Colleen Young
 
Interactive subway map
Interactive subway mapInteractive subway map
Interactive subway map
 
Dijekstra algorithm
Dijekstra algorithmDijekstra algorithm
Dijekstra algorithm
 
graph theory
graph theory graph theory
graph theory
 
Binary Search Algorithm
Binary Search Algorithm Binary Search Algorithm
Binary Search Algorithm
 
History Of Linux
History Of LinuxHistory Of Linux
History Of Linux
 
Operating Systems: A History of Linux
Operating Systems: A History of LinuxOperating Systems: A History of Linux
Operating Systems: A History of Linux
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 

Semelhante a Networks dijkstra's algorithm- pgsr

Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithmmeisamstar
 
35 dijkstras alg
35 dijkstras alg35 dijkstras alg
35 dijkstras algdouglaslyon
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpathKrish_ver2
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...KUSHDHIRRA2111026030
 
Jaimin chp-5 - network layer- 2011 batch
Jaimin   chp-5 - network layer- 2011 batchJaimin   chp-5 - network layer- 2011 batch
Jaimin chp-5 - network layer- 2011 batchJaimin Jani
 
2.3 shortest path dijkstra’s
2.3 shortest path dijkstra’s 2.3 shortest path dijkstra’s
2.3 shortest path dijkstra’s Krish_ver2
 
2.4 mst prim’s algorithm
2.4 mst  prim’s algorithm2.4 mst  prim’s algorithm
2.4 mst prim’s algorithmKrish_ver2
 
19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structureEMEY GUJJAR
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest pathMohammad Akbarizadeh
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emadKazi Emad
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2MuradAmn
 
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION NUMBER OF TENEMENT GRAPHS
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION  NUMBER OF TENEMENT GRAPHSAN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION  NUMBER OF TENEMENT GRAPHS
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION NUMBER OF TENEMENT GRAPHSBRNSS Publication Hub
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slidesHJ DS
 
Dijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithmDijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithmDelowar Hossain
 
Bellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
Bellman-Ford-Moore Algorithm and Dijkstra’s AlgorithmBellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
Bellman-Ford-Moore Algorithm and Dijkstra’s AlgorithmFulvio Corno
 

Semelhante a Networks dijkstra's algorithm- pgsr (20)

Dijesktra 1.ppt
Dijesktra 1.pptDijesktra 1.ppt
Dijesktra 1.ppt
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
 
12_Graph.pptx
12_Graph.pptx12_Graph.pptx
12_Graph.pptx
 
35 dijkstras alg
35 dijkstras alg35 dijkstras alg
35 dijkstras alg
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
DAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptxDAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptx
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
Jaimin chp-5 - network layer- 2011 batch
Jaimin   chp-5 - network layer- 2011 batchJaimin   chp-5 - network layer- 2011 batch
Jaimin chp-5 - network layer- 2011 batch
 
2.3 shortest path dijkstra’s
2.3 shortest path dijkstra’s 2.3 shortest path dijkstra’s
2.3 shortest path dijkstra’s
 
2.4 mst prim’s algorithm
2.4 mst  prim’s algorithm2.4 mst  prim’s algorithm
2.4 mst prim’s algorithm
 
19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure19 prim,kruskal alg. in data structure
19 prim,kruskal alg. in data structure
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
 
Floyd aaaaaa
Floyd aaaaaaFloyd aaaaaa
Floyd aaaaaa
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2
 
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION NUMBER OF TENEMENT GRAPHS
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION  NUMBER OF TENEMENT GRAPHSAN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION  NUMBER OF TENEMENT GRAPHS
AN ASSESSMENT ON THE SPLIT AND NON-SPLIT DOMINATION NUMBER OF TENEMENT GRAPHS
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Dijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithmDijsktra’s Sortest path algorithm
Dijsktra’s Sortest path algorithm
 
Bellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
Bellman-Ford-Moore Algorithm and Dijkstra’s AlgorithmBellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
Bellman-Ford-Moore Algorithm and Dijkstra’s Algorithm
 

Último

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Networks dijkstra's algorithm- pgsr

  • 1. DIJKSTRA'S ALGORITHM, BY DR HJH RAHMAH BT MURSHIDI
  • 2. INTRODUCTION  Dijkstra's algorithm, named after its discoverer, Dutch computer scientist Edsger Dijkstra  A greedy algorithm that solves the single-source shortest path problem for a directed graph with non negative edge weights.
  • 3. INTRODUCTION  For example, if the vertices of the graph represent cities and edge weights represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between two cities.
  • 4.  The input of the algorithm consists of a weighted directed graph G and a source vertex s in G  Denote V as the set of all vertices in the graph G.  Each edge of the graph is an ordered pair of vertices (u,v)  This representings a connection from vertex u to vertex v
  • 5.  The set of all edges is denoted E  Weights of edges are given by a weight function w: E → [0, ∞)  Therefore w(u,v) is the cost of moving directly from vertex u to vertex v  The cost of an edge can be thought of as (a generalization of) the distance between those two vertices
  • 6.  The cost of a path between two vertices is the sum of costs of the edges in that path  For a given pair of vertices s and t in V, the algorithm finds the path from s to t with lowest cost (i.e. the shortest path)  It can also be used for finding costs of shortest paths from a single vertex s to all other vertices in the graph.
  • 7. BOXES AT EACH NODE Order of labelling Label (i.e Permanent label) Working values
  • 8. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM FROM S TO T S A B T D C 3 11 5 8 6 4 1 2 4 Step 1 Label start node S with permanent label (P-label) of 0. 1 0 4
  • 9. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 4 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 2 For all nodes that can be reached directly from S, assign temporary labels (T-labels) equal to their direct distance from S 6 4
  • 10. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 4 2 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 3 Select the node with smallest T label and makes its label permanent. In this case the node is A. The P-label represents the shortest distance from S to that node. Put the order of labeling as 2. 6
  • 11. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 4 2 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 4 Consider all nodes that can be reached from A, that are B and T. Shortest route from S to B via A is 3+4 =7, but B is already labelled as 6 and it’s the best so far. The shortest route from S to T via A is 3 + 11 = 14. Put T-label as 14 in T 6 4 14
  • 12. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 3 4 2 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 5 Compare node T, B and C. The smallest T label is now 4 at C. Since this value cannot be improved, it becomes P-label of 4. Put the order of labeling at C as 3 6 4 14
  • 13. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 3 4 2 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 6 Consider all nodes that can be reached from C, that are B and D. Shortest route from S to B via C is 4+1 =5 which is shorter than 6. Change T label 6 to P label 5. The shortest route from S to D via C is 4 + 4 = 8. Put T- label as 8 in D. Compare B and D. B is less than D, so the next node is B. Put the order of labeling at B as 4 4 5 4 14 8
  • 14. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 3 4 4 2 3 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 7 Consider all nodes that can be reached from B; that are D and T. Shortest route from S to D via B is 5+2 =7 which is shorter than 8. Change T label 8 to P label 7. The shortest route from S to T via B is 5 + 8 = 13. This is smaller than 14 so change to 13 in T as T label. Compare T and D. D is less than T so chose D as the next node. Put the order of labeling as 5 in D 4 5 6,5 4 6 13 14,13 5 7 8,7
  • 15. TO FIND THE SHORTEST ROUTE BY DIJKSTRA’S ALGORITHM 3 4 4 2 3 3 1 0 S A B T D C 3 11 5 8 6 4 1 2 4 Step 8 The last node is T. Put the order of labeling as 6 in T. Compare the routes from S to T via A (3 + 11 =14), via B ( 5 + 8 =13) and via D (7 + 5 =12). It seems that the shortest route from S to T is via D. Change the T label in T (13) to P label with the value 12. Therefore the shortest way from S to T is SCBDT which is 12 4 5 6,5 4 6 12 14,13,12 5 7 8,7