15.082J & 6.855J & ESD.78J Shortest Paths 2: Bucket implementations of Dijkstra’s Algorithm R-Heaps.

Slides:



Advertisements
Similar presentations
and 6.855J Dijkstras Algorithm with simple buckets (also known as Dials algorithm)
Advertisements

Single Source Shortest Paths
AVL Trees COL 106 Amit Kumar Shweta Agrawal Slide Courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
Greedy Algorithms Amihood Amir Bar-Ilan University.
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
and 6.855J February 25, 2003 Radix Heap Animation.
Lecture 6 Shortest Path Problem. s t Dynamic Programming.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Theory of Computing Lecture 8 MAS 714 Hartmut Klauck.
15.082J, 6.855J, and ESD.78J Sept 16, 2010 Lecture 3. Graph Search Breadth First Search Depth First Search Intro to program verification Topological Sort.
CSCI 3160 Design and Analysis of Algorithms Tutorial 2 Chengyu Lin.
Chapter 7 Maximum Flows: Polynomial Algorithms
Jean-Charles REGIN Michel RUEHER ILOG Sophia Antipolis Université de Nice – Sophia Antipolis A global constraint combining.
© 2004 Goodrich, Tamassia Shortest Paths1 Shortest Paths (§ 13.6) Given a weighted graph and two vertices u and v, we want to find a path of minimum total.
15.082J/6.855J/ESD.78J September 14, 2010 Data Structures.
Computational Methods for Management and Economics Carla Gomes
& 6.855J & ESD.78J Algorithm visualizations Modified Label Correcting Algorithm.
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
Minimum Cost Flows. 2 The Minimum Cost Flow Problem u ij = capacity of arc (i,j). c ij = unit cost of shipping flow from node i to node j on (i,j). x.
Lecture 10 The Label Correcting Algorithm.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
15.082J and 6.855J and ESD.78J October 19, 2010 Max Flows 3 Preflow-Push Algorithms.
CSC 211 Data Structures Lecture 13
15.082J & 6.855J & ESD.78J September 23, 2010 Dijkstra’s Algorithm for the Shortest Path Problem.
Data Structure & Algorithm II.  In a multiuser computer system, multiple users submit jobs to run on a single processor.  We assume that the time required.
& 6.855J & ESD.78J Algorithm Visualization The Ford-Fulkerson Augmenting Path Algorithm for the Maximum Flow Problem.
and 6.855J The Goldberg-Tarjan Preflow Push Algorithm for the Maximum Flow Problem.
15.082J and 6.855J and ESD.78J The Successive Shortest Path Algorithm and the Capacity Scaling Algorithm for the Minimum Cost Flow Problem.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
FALL 2005CENG 213 Data Structures1 Priority Queues (Heaps) Reference: Chapter 7.
Week 14 - Monday.  What did we talk about last time?  Heaps  Priority queues  Heapsort.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘length’ c ij (cost, time, distance, …). Determine a path of shortest.
1 Chapter 6 Heapsort. 2 About this lecture Introduce Heap – Shape Property and Heap Property – Heap Operations Heapsort: Use Heap to Sort Fixing heap.
EMIS 8374 The Ford-Fulkerson Algorithm (aka the labeling algorithm) Updated 4 March 2008.
15.082J and 6.855J and ESD.78J Network Simplex Animations.
1 Maximum Flows CONTENTS Introduction to Maximum Flows (Section 6.1) Introduction to Minimum Cuts (Section 6.1) Applications of Maximum Flows (Section.
School of Computing Clemson University Fall, 2012
Lecture: Priority Queue
Cycle Canceling Algorithm
Shortest Paths CONTENTS Introduction to Shortest Paths (Section 4.1)
EMIS 8374 Dijkstra’s Algorithm Updated 18 February 2008
Dijkstra’s Algorithm with two levels of buckets
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
15.082J & 6.855J & ESD.78J Visualizations
Dijkstra’s Algorithm for the Shortest Path Problem
15.082J & 6.855J & ESD.78J Visualizations
Lecture 6 Shortest Path Problem.
Dijkstra’s Algorithm for the Shortest Path Problem
Breadth first search animation
Shortest-Path Property 4.1
Lower bound for sorting, radix sort
Successive Shortest Path Algorithm
and 6.855J March 6, 2003 Maximum Flows 2
15.082J & 6.855J & ESD.78J Radix Heap Animation
Network Optimization Depth First Search
Min Global Cut Animation
Network Optimization Flow Decomposition.
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
The Shortest Augmenting Path Algorithm for the Maximum Flow Problem
Network Optimization Topological Ordering
Visualizations Dijkstra’s Algorithm
15.082J & 6.855J & ESD.78J Visualizations
Implementation of Dijkstra’s Algorithm
OPIM 915 Fall 2010 Data Structures 23-38,
Introduction to Minimum Cost Flows
Max Flows 3 Preflow-Push Algorithms
Class 11 Max Flows Obtain a network, and use the same network to illustrate the shortest path problem for communication networks, the max flow.
Week 13 - Wednesday CS221.
15.082J & 6.855J & ESD.78J Visualizations
Presentation transcript:

15.082J & 6.855J & ESD.78J Shortest Paths 2: Bucket implementations of Dijkstra’s Algorithm R-Heaps

2 A Simple Bucket-based Scheme Let C = 1 + max(c ij : (i,j) ∈ A); then nC is an upper bound on the minimum length path from 1 to n. RECALL: When we select nodes for Dijkstra's Algorithm we select them in increasing order of distance from node 1. SIMPLE STORAGE RULE. Create buckets from 0 to nC. Let BUCKET(k) = {i ∈ T: d(i) = k}. Buckets are sets of nodes stored as doubly linked lists. O(1) time for insertion and deletion.

3 Dial’s Algorithm u Whenever d(j) is updated, update the buckets so that the simple bucket scheme remains true. u The FindMin operation looks for the minimum non-empty bucket. u To find the minimum non-empty bucket, start where you last left off, and iteratively scan buckets with higher numbers. Dial’s Algorithm

4 Running time for Dial’s Algorithm  C = 1 + max(c ij : (i,j) ∈ A). u Number of buckets needed. O(nC) u Time to create buckets. O(nC) u Time to update d( ) and buckets. O(m) u Time to find min. O(nC). u Total running time. O(m+ nC). u This can be improved in practice; e.g., the space requirements can be reduced to O(C).

5 Additional comments on Dial’s Algorithm u Create buckets when needed. Stop creating buckets when each node has been stored in a bucket. u Let d* = max {d*(j): j ∈ N}. Then the maximum bucket ever used is at most d* + C. Suppose j ∈ Bucket( d* + C + 1) after update(i). But then d(j) = d(i) + c ij ≤ d* + C d*d*+1 j d*+2d*+3 d*+Cd*+C+1 ∅

A 2-level bucket scheme u Have two levels of buckets. Lower buckets are labeled 0 to K-1 (e.g., K = 10) Upper buckets all have a range of K. First upper bucket’s range is K to 2K – 1. Store node j in the bucket whose range contains d(j) distance label

Find Min u FindMin consists of two subroutines SearchLower: This procedure searches lower buckets from left to right as in Dial’s algorithm. When it finds a non-empty bucket, it selects any node in the bucket. SearchUpper: This procedure searches upper buckets from left to right. When it finds a bucket that is non-empty, it transfers its elements to lower buckets. 7 FindMin If the lower buckets are non-empty, then SearchLower; Else, SearchUpper and then SearchLower.

More on SearchUpper u SearchUpper is carried out when the lower buckets are all empty. u When SearchUpper finds a non-empty bucket, it transfers its contents to lower buckets. First it relabels the lower buckets Level Bucket Algorithm

Running Time Analysis u Time for SearchUpper: O(nC/K) O(1) time per bucket u Number of times that the Lower Buckets are filled from the upper buckets: at most n. u Total time for FindMin in SearchLower O(nK); O(1) per bucket scanned. u Total Time for scanning arcs and placing nodes in the correct buckets: O(m) u Total Run Time: O(nC/K + nK + m). Optimized when K = C.5 O(nC.5 + m) 9

More on multiple bucket levels u Running time can be improved with three or more levels of buckets. u Runs great in practice with two levels u Can be improved further with buckets of range (width) 1, 1, 2, 4, 8, 16 … Radix Heap Implementation 10

11 A Special Purpose Data Structure u RADIX HEAP: a specialized implementation of priority queues for the shortest path problem. u A USEFUL PROPERTY (of Dijkstra's algorithm): The minimum temporary label d( ) is monotonically non-decreasing. The algorithm labels node in order of increasing distance from the origin. u C = 1 + max length of an arc

12 Radix Heap Example Buckets: bucket sizes grow exponentially ranges change dynamically Radix Heap Animation

Analysis: FindMin u Scan from left to right until there is a non-empty bucket. If the bucket has width 1 or a single element, then select an element of the bucket. Time per find min: O(K), where K is the number of buckets

Analysis: Redistribute Range u Redistribute Range: suppose that the minimum non-empty bucket is Bucket j. Determine the min distance label d* in the bucket. Then distribute the range of Bucket j into the previous j-1 buckets, starting with value d*. Time per redistribute range: O(K). It takes O(1) steps per bucket. Time for determining d*: see next slide d(5) = 9 (min label)

Analysis: Find min d(j) for j in bucket u Let b the the number of items in the minimum bucket. The time to find the min distance label of a node in the bucket is O(b). Every item in the bucket will move to a lower index bucket after the ranges are redistributed. Thus, the time to find d* is dominated by the time to update contents of buckets. We analyze that next 15

Analysis: Update Contents of Buckets u When a node j needs to move buckets, it will always shift left. Determine the correct bucket by inspecting buckets one at a time. O(1) whenever we need to scan the bucket to the left. For node j, updating takes O(K) steps in total d(5) = 9 5

Running time analysis u FindMin and Redistribute ranges O(K) per iteration. O(nK) in total u Find minimum d(j) in bucket Dominated by time to update nodes in buckets u Scanning arcs in Update O(1) per arc. O(m) in total. u Updating nodes in Buckets O(K) per node. O(nK) in total u Running time: O(m + nK) O(m + n log nC) u Can be improved to O(m + n log C) 17

18 Summary u Simple bucket schemes: Dial’s Algorithm u Double bucket schemes: Denardo and Fox’s Algorithm u Radix Heap: A bucket based method for shortest path buckets may be redistributed simple implementation leads to a very good running time unusual, global analysis of running time

MITOpenCourseWare J / 6.855J / ESD.78J Network Optimization Fall 2010 For information about citing these materials or our Terms of Use, visit: