Implementation of Dijkstra - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Implementation of Dijkstra

Description:

Implementation of Dijkstra s Algorithm Dijkstra s Algorithm Implementations With min-priority queue, Dijkstra algorithm can be implemented in time With ... – PowerPoint PPT presentation

Number of Views:183
Avg rating:3.0/5.0
Slides: 21
Provided by: Lenov163
Category:

less

Transcript and Presenter's Notes

Title: Implementation of Dijkstra


1
Implementation of Dijkstras Algorithm
2
Dijkstras Algorithm
3
Implementations
  • With min-priority queue, Dijkstra algorithm can
    be
  • implemented in time
  • With Fibonacci heap, Dijkstra algorithm can be
    implemented
  • in time
  • With Radix heap, Dijkstra algorithm can be
    implemented
  • in time

4
An Example
?
?
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
3
5
?
?
1
0
Initialize
2
3
8
8
Select the node with the minimum temporary
distance label.
4
5
6
8
8
8
5
Update Step
2
?
?
4
2
4
2
2
0
2
1
3
?
6
1
4
2
3
3
5
?
?
1
0
4
2
3
2
4
Decrease-Key(S,2,2) Decrease-Key(S,3,4)
4
5
6
8
8
8
6
Update Step
2
?
?
4
2
4
2
2
0
2
1
3
?
6
1
4
2
3
3
5
?
?
8
6
4
2
3
2
4
Extract-Min(S)
4
5
8
8
7
Choose Minimum Temporary Label
2
?
4
4
2
2
2
0
2
1
3
?
1
6
4
2
3
3
5
?
4
2
2
6
3
4
8
4
5
8
8
8
Update Step
The predecessor of node 3 is now node 2
6
2
?
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
3
5
?
4
2
2
4
3
5
3
3
4
Decrease-Key(S,3,3) Decrease-Key(S,4,6) Decrease-K
ey(S,5,4)
6
4
8
6
9
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
5
3
3
4
6
4
5
3
3
4
Extract-Min(S)
6
8
10
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
5
3
3
4
3
3
5
4
6
4
Extract-Min(S)
6
8
11
Update
2
6
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
5
3
3
4
3
3
5
4
6
4
d(5) is not changed.
6
8
12
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
3
5
3
4
6
8
5
4
6
4
Extract-Min(S)
13
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
?
1
6
4
2
3
3
5
3
4
5
4
6
4
6
Extract-Min(S)
8
14
Update
d(4) is not changed
2
6
4
2
4
2
2
0
6
2
1
3
?
1
6
4
2
3
3
5
3
4
5
4
6
4
6
6
Decrease-Key(S,6,6)
15
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
6
1
6
4
2
3
3
5
3
4
4
6
6
6
16
Update
2
6
4
2
4
2
2
0
2
1
3
6
1
6
4
2
3
3
5
3
4
4
6
6
6
d(6) is not updated
17
Choose Minimum Temporary Label
2
6
4
2
4
2
2
0
2
1
3
6
1
6
4
2
3
3
5
3
4
6
6
There is nothing to update
18
End of Algorithm
2
6
4
2
4
2
2
0
2
1
3
6
1
6
4
2
3
3
5
3
4
All nodes are now permanent
The predecessors form a tree
The shortest path from node 1 to node 6 can be
found by tracing back predecessors
19
Implementations
  • Decrease-Key(S,x,key) Call at most m times.
  • Extract-Min(S) Call n times.
  • With min-priority queue, Dijkstra algorithm can
    be
  • implemented in time

20
Compared with Dynamic Programming
  • Dijkstras algorithm uses O(n) space.
  • Dynamic programming uses O(m) space.
Write a Comment
User Comments (0)
About PowerShow.com