1 / 31

Reading Material

Reading Material. Shortest Paths 2: R-Heaps. Radix Heap Animation. . . 5. 2. 4. 15. 2. 13. 0. . 1. 6. 20. 0. 8. 9. 3. 5. . . . An Example from AMO (with a small change). Initialize distance labels. Initialize buckets and their ranges. Insert nodes into buckets.

jdandrea
Download Presentation

Reading Material

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reading Material Shortest Paths 2: R-Heaps

  2. Radix Heap Animation

  3.  5 2 4 15 2 13 0  1 6 20 0 8 9 3 5    An Example from AMO (with a small change) Initialize distance labels Initialize buckets and their ranges. Insert nodes into buckets. 2 3 47 8 15 16 31 3263 2 0 1 3 4 5 1 6

  4. Select   5 Select the node with minimum distance label 2 4 15 2 13 0  1 1 6 20 0 8 9 3 5   2 3 47 8 15 16 31 3263 2 0 1 3 4 5 1 6

  5.  0     Update 13 15 5 Scan arcs out of node 1 and update distance labels. 2 4 15 2 13 1 1 6 20 0 8 9 3 5 0 20 2 3 47 8 15 16 31 3263 2 0 1 3 4 2 5 5 3 4 6

  6. Select 13 15 5 Select the node with minimum distance label 2 4 15 2 13 0  1 1 6 Node 3 has label 0, which is minimum. 20 0 8 9 3 3 5 0 20 2 3 47 8 15 16 31 3263 0 1 2 5 6 3 4

  7. Update 13 15 5 Scan arcs out of node 3 and update distance labels. 2 4 15 2 13 0  1 1 6 20 0 8 9 3 3 5 0 20 9 2 3 47 8 15 16 31 3263 0 1 2 5 6 3 4 5

  8. Select: part 1 13 15 5 Find the first non-empty bucket, by scanning buckets from left to right. 2 4 15 2 13 0  1 1 6 20 0 8 9 3 3 5 0 20 9 2 3 47 8 15 16 31 3263 0 1 2 6 4 5

  9. Select: part 2 13 15 5 Determine the minimum distance value in the bucket, by scanning all nodes in the bucket. 2 4 15 2 13 0  1 1 6 20 0 8 9 3 3 5 d(5) = 9, which is minimum. 0 20 9 2 3 47 8 15 16 31 3263 0 1 2 6 4 5

  10. Select: part 3 13 15 5 Redistribute the range of bucket 5 into the first 4 buckets, starting with value 9. Bucket widths stay the same, except that some may be smaller. 2 4 15 2 13 0  1 1 6 20 0 8 9 3 3 5 0 20 9 11 12 1315 2 3 47  8 15 16 31 3263 0 9 1 10 2 6 4 5

  11. Select: part 4 13 15 5 Reinsert nodes in the correct bucket. Determine the bucket by scanning left. 2 4 15 2 13 0  1 1 6 20 0 8 9 At this point the leftmost bucket is non-empty 3 3 5 0 20 9 2 3 11 12 1315  8 15 16 31 3263 0 9 10 1 2 6 2 5 4 4 5

  12. Select: part 5 13 15 5 Select a node in the leftmost bucket. 2 4 15 2 13 0  1 1 6 20 0 8 9 3 3 5 5 0 20 9 2 3 11 12 1315 8 15  16 31 3263 0 9 10 1 6 2 5 4

  13. Update 13 15 5 Scan arcs out of node 5 and update distance labels. 2 4 15 2 13 0  17 1 1 6 Reinsert nodes in correct buckets by scanning left. 20 0 8 9 3 3 5 5 0 20 9 2 3 11 12 1315  8 15 16 31 3263 0 9 1 10 6 2 6 4

  14. Select: parts 1 and 2 13 15 5 Find the minimum non-empty bucket. 2 4 15 2 13 0 17  1 1 6 Find the minimum distance label in the bucket 20 0 8 9 3 3 5 5 0 20 9 11 12 2 3 1315  8 15 16 31 3263 0 9 1 10 2 6 4

  15. Select: parts 3 and 4 13 15 5 Redistribute bucket ranges in the minimum bucket 2 4 15 2 13 0  17 1 1 6 Reinsert nodes in correct buckets. 20 0 8 9 3 3 5 5 0 20 9 2 3 11 12 15 1315   8 15 16 31 3263 0 13 9 14 1 10 2 2 4 6 4

  16. Select: part 5 13 15 5 Select a node from the leftmost bucket. 2 2 4 15 2 13 0 17  1 1 6 20 0 8 9 3 3 5 5 0 20 9 15 11 12 2 3  1315 8 15  16 31 3263 0 9 13 1 10 14 2 4 6

  17. Update 13 15 5 Scan the arc out of node 2. 2 2 4 15 2 13 0 17  1 1 6 20 0 8 9 3 3 5 5 0 20 9 15 2 3 11 12 1315  8 15  16 31 3263 0 9 13 1 14 10 4 6

  18. Select, Modified rule 1 13 15 5 Find the minimum non-empty bucket 2 2 4 4 15 2 13 0  17 If the bucket has a width of 1, select any node in the bucket. 1 1 6 20 0 8 9 3 3 5 5 0 20 9 15 11 12 2 3 1315  8 15  16 31 3263 0 13 9 10 14 1 4 6

  19. Update 13 15 5 Scan the arc out of node 4 2 2 4 4 15 2 13 0  17 1 1 6 20 0 8 9 3 3 5 5 0 20 9 15 2 3 11 12 1315  8 15  16 31 3263 0 9 13 1 14 10 6

  20. Select: modified rule 2 13 15 5 Find the minimum non-empty bucket 2 2 4 4 15 2 13 If the bucket has a single node, then select the node. 0 17  1 1 6 6 20 0 Modified rules and heuristics often help in practice, but must be used carefully. 8 9 3 3 5 5 0 20 9 11 12 15 2 3 1315   8 15 16 31 3263 0 9 13 10 14 1 6

  21. The algorithm ends 13 15 5 There are no arcs to update. 2 2 4 4 15 2 13 0 17  1 1 6 6 There are no nodes that need to be permanently labeled. 20 0 8 9 3 3 5 5 0 20 9 15 11 12 2 3 1315   8 15 16 31 3263 0 9 13 1 14 10

  22. Exercise • Solve the shortest path problem shown in Figure 4.15(a) (page127 in textbook) using the Radix-heap algorithm

More Related