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

More Related Content

What's hot

Dijkstra
DijkstraDijkstra
Dijkstra
jagdeeparora86
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
Amit Kumar Rathi
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
Tamzida_Azad
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
guest862df4e
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
Tanmay Baranwal
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
sana younas
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
AnuragChaudhary70
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
Md. Shafiuzzaman Hira
 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
University of Potsdam
 
Kruskal’s Algorithm
Kruskal’s AlgorithmKruskal’s Algorithm
Kruskal’s Algorithm
Syed Maniruzzaman Pabel
 
DAA-Floyd Warshall Algorithm.pptx
DAA-Floyd Warshall Algorithm.pptxDAA-Floyd Warshall Algorithm.pptx
DAA-Floyd Warshall Algorithm.pptx
ArbabMaalik
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
Bhavik Vashi
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Amit Kumar Rathi
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
taimurkhan803
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
Roshan Tailor
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
Salman Elahi
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraq
montaser185
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
Saga Valsalan
 

What's hot (20)

Dijkstra
DijkstraDijkstra
Dijkstra
 
Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Graph algorithm
Graph algorithmGraph algorithm
Graph algorithm
 
Kruskal’s Algorithm
Kruskal’s AlgorithmKruskal’s Algorithm
Kruskal’s Algorithm
 
DAA-Floyd Warshall Algorithm.pptx
DAA-Floyd Warshall Algorithm.pptxDAA-Floyd Warshall Algorithm.pptx
DAA-Floyd Warshall Algorithm.pptx
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
 
Optimal binary search tree dynamic programming
Optimal binary search tree   dynamic programmingOptimal binary search tree   dynamic programming
Optimal binary search tree dynamic programming
 
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraq
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
 

Viewers also liked

Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
Onggo Wiryawan
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithm
Pulkit 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 algorithm
Srikrishnan 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
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
Hyungyu Shin
 
Class 8b: Numpy & Matplotlib
Class 8b: Numpy & MatplotlibClass 8b: Numpy & Matplotlib
Class 8b: Numpy & Matplotlib
Marc 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 dijkstra
adarsh
 
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
PyData
 
Path cycle part1
Path cycle part1Path cycle part1
Path cycle part1
guestb63941
 
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
Wen-Wei Liao
 
Dijksatra
DijksatraDijksatra
Dijksatra
Tanmay Baranwal
 
Dijkstra's Algorithm - Colleen Young
Dijkstra's Algorithm  - Colleen YoungDijkstra's Algorithm  - Colleen Young
Dijkstra's Algorithm - Colleen Young
Colleen Young
 
Interactive subway map
Interactive subway mapInteractive subway map
Interactive subway map
Konstantin Chukhlomin
 
graph theory
graph theory graph theory
graph theory
ganith2k13
 
Binary Search Algorithm
Binary Search Algorithm Binary Search Algorithm
Binary Search Algorithm
Anastasia Jakubow
 
History Of Linux
History Of LinuxHistory Of Linux
History Of Linux
anand09
 
Operating Systems: A History of Linux
Operating Systems: A History of LinuxOperating Systems: A History of Linux
Operating Systems: A History of Linux
Damian T. Gordon
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
Venkatesh Iyer
 

Viewers also liked (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
 

Similar to Networks dijkstra's algorithm- pgsr

Dijesktra 1.ppt
Dijesktra 1.pptDijesktra 1.ppt
Dijesktra 1.ppt
DEEPAK948083
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
Ruchika Sinha
 
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithmAAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
SantoshDood
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
meisamstar
 
Shortest path
Shortest pathShortest path
Shortest path
Farah Shaikh
 
12_Graph.pptx
12_Graph.pptx12_Graph.pptx
12_Graph.pptx
TELAPROLULAKSHMISRIN
 
35 dijkstras alg
35 dijkstras alg35 dijkstras alg
35 dijkstras alg
douglaslyon
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
sakthibalabalamuruga
 
DAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptxDAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptx
AndrewJohnson866415
 
2.6 all pairsshortestpath
2.6 all pairsshortestpath2.6 all pairsshortestpath
2.6 all pairsshortestpath
Krish_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 batch
Jaimin 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 algorithm
Krish_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 structure
EMEY GUJJAR
 
Randomized algorithms all pairs shortest path
Randomized algorithms  all pairs shortest pathRandomized algorithms  all pairs shortest path
Randomized algorithms all pairs shortest path
Mohammad Akbarizadeh
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
Kazi Emad
 
Floyd aaaaaa
Floyd aaaaaaFloyd aaaaaa
Floyd aaaaaa
Pradeep Bisht
 
04 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x204 greedyalgorithmsii 2x2
04 greedyalgorithmsii 2x2
MuradAmn
 
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
BRNSS Publication Hub
 

Similar to Networks dijkstra's algorithm- pgsr (20)

Dijesktra 1.ppt
Dijesktra 1.pptDijesktra 1.ppt
Dijesktra 1.ppt
 
Dijkstra.ppt
Dijkstra.pptDijkstra.ppt
Dijkstra.ppt
 
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithmAAD_Lec-3-B-ShortestPaths.ppt  of design and analysis of algorithm
AAD_Lec-3-B-ShortestPaths.ppt of design and analysis of algorithm
 
Unit26 shortest pathalgorithm
Unit26 shortest pathalgorithmUnit26 shortest pathalgorithm
Unit26 shortest pathalgorithm
 
Shortest path
Shortest pathShortest path
Shortest path
 
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
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 

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