210 likes | 351 Views
Dive into the intricate details of Dijkstra's Algorithm, enhanced with a visualization technique that uses two levels of buckets. This approach effectively manages distance labels during the shortest pathfinding process, demonstrating the selection of nodes from non-empty buckets, updating distance structures, and managing arc scans. The method is designed for those eager to understand the optimization of network paths clearly and intuitively. Perfect for students and enthusiasts of computer science, this resource is derived from MIT OpenCourseWare’s Network Optimization course.
E N D
15.082J & 6.855J & ESD.78JVisualizations Dijkstra’s Algorithm with two levels of buckets
∞ ∞ 0 ∞ ∞ ∞ ∞ 2 3 4 5 6 Initialize Initialize distance labels 46 2 4 8 18 Initialize buckets. 22 25 26 1 6 Select the first nonempty lower bucket. Then select an element of the bucket. 1 41 25 37 3 5 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 0 1 2 3 4 5 6 7 8 9 1
1 ∞ Update ∞ ∞ 8 Scan arcs out of node 1 and update data structures 46 2 4 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 41 ∞ ∞ 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 2 3 4 0 1 2 3 4 5 6 7 8 9 5 1 6
1 ∞ Find Min Lower Bucket ∞ 8 Find min non-empty lower bucket. Select a node in the bucket. 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 41 ∞ 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 3 4 0 1 2 3 4 5 6 7 8 9 5 2 6
1 ∞ Update ∞ 8 54 Scan arcs out of node 2 and update distance labels and buckets. 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 33 30 41 ∞ 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 3 4 0 1 2 3 4 5 6 7 8 9 5 2 6
1 ∞ Find Min Lower Bucket 54 8 Scan lower bucket for first non-empty bucket. If none exist, then go to scanning upper buckets. 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 33 30 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 3 4 5 0 1 2 3 4 5 6 7 8 9 6
1 ∞ Find Min Upper Bucket 54 8 Scan upper buckets to find the first non-empty bucket. 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 33 30 10-19 20-29 30-39 40-49 50-59 60-69 70-79 80-89 90-99 3 4 5 0 1 2 3 4 5 6 7 8 9 6
1 ∞ Move contents down 54 8 Adjust bucket numbers of lower buckets and move contents of upper bucket to lower buckets 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 33 30 30-39 40-49 50-59 60-69 70-79 80-89 90-99 3 4 5 30 0 1 31 32 2 3 33 4 34 5 35 6 36 7 37 8 38 9 39 6
1 ∞ Find Min Lower Bucket 54 8 Find the first nonempty lower bucket and select a node in the bucket 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 25 37 3 5 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 30 31 32 33 34 35 36 37 38 39 5 3 6
1 ∞ Update 54 8 Scan arcs out of node 5 and update distance labels and buckets. 46 2 4 2 8 18 0 22 25 26 ∞ 1 6 41 55 25 37 3 5 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 30 31 32 33 34 35 36 37 38 39 5 3 6
1 Find Min Lower Bucket 54 8 Find the first nonempty lower bucket and select a node in the bucket 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 3 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 6 30 31 32 33 34 35 36 37 38 39 3
1 Update 54 8 Scan arcs out of node 3 and perform updates. 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 3 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 6 30 31 32 33 34 35 36 37 38 39 3
1 Find Min Lower Bucket 54 8 Scan lower buckets looking for a non-empty bucket. 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 6 30 31 32 33 34 35 36 37 38 39
1 Find Min Upper Bucket 54 8 Scan upper buckets looking for a non-empty bucket. 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 40-49 50-59 60-69 70-79 80-89 90-99 4 6 30 31 32 33 34 35 36 37 38 39
1 Move contents down 54 8 Adjust bucket numbers of lower buckets and move contents of upper bucket to lower buckets. 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 50-59 60-69 70-79 80-89 90-99 4 6 30 50 51 31 32 52 33 53 34 54 35 55 36 56 37 57 58 38 59 39
1 Find Min Lower Bucket 54 8 Select the min non-empty lower bucket. Select an element from the bucket. 46 2 4 2 4 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 60-69 70-79 80-89 90-99 50 51 52 53 54 55 56 57 58 59 4 6
1 Update 54 8 Scan arcs out of node 4 and perform all updates. 46 2 4 2 4 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 60-69 70-79 80-89 90-99 50 51 52 53 54 55 56 57 58 59 4 6
1 Find Min Lower Bucket 54 8 Scan lower buckets looking for a non-empty bucket. Select a node of the bucket 46 2 4 2 6 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 60-69 70-79 80-89 90-99 50 51 52 53 54 55 56 57 58 59 6
1 Update 54 8 Scan arcs out of node 6, and perform updates 46 2 4 2 6 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 60-69 70-79 80-89 90-99 50 51 52 53 54 55 56 57 58 59 6
1 Termination 54 8 All nodes are permanent. The algorithm terminates with the optimal shortest path tree. 46 2 4 2 8 18 0 22 25 26 1 6 41 55 25 37 3 5 5 33 30 60-69 70-79 80-89 90-99 50 51 52 53 54 55 56 57 58 59
MITOpenCourseWare http://ocw.mit.edu 15.082J / 6.855J / ESD.78J Network Optimization Fall 2010 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.