Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Dijkstra's Shortest Path Algorithm
Bookmark
Input
4 Nodes
5 Nodes
6 Nodes
Custom
graph
=
{"A":[["B",1],["C",4]],"B":[["A",1],["C",2]],"C":[["A",4],["B",2],["D",3]],"D":[["C",3]]}
,
source
=
A
Dijkstra's Shortest Path (source: A)
1
4
2
3
A
B
C
D
0
∞
∞
∞
Distances:
A
0
B
∞
C
∞
D
∞
Visited:
(none)
Min-Heap (Priority Queue):
(empty)
Legend:
Unvisited
Current
Checking
Visited
algo
master
.
io
Step:
Initialize distances: source "A" = 0, all others = ∞
0 / 28
Input
4 Nodes
5 Nodes
6 Nodes
Custom
graph
=
{"A":[["B",1],["C",4]],"B":[["A",1],["C",2]],"C":[["A",4],["B",2],["D",3]],"D":[["C",3]]}
,
source
=
A
0 / 28
Dijkstra's Shortest Path (source: A)
1
4
2
3
A
B
C
D
0
∞
∞
∞
Distances:
A
0
B
∞
C
∞
D
∞
Visited:
(none)
Min-Heap (Priority Queue):
(empty)
Legend:
Unvisited
Current
Checking
Visited
algo
master
.
io
Step:
Initialize distances: source "A" = 0, all others = ∞