By Amber McKenzie and Laura Boccanfuso. Dijkstra’s Algorithm Question: How do you know that Dijkstra’s algorithm finds the shortest path and is optimal.

Slides:



Advertisements
Similar presentations
Fibonacci Heaps Especially desirable when the number of calls to Extract-Min & Delete is small (note that all other operations run in O(1) This arises.
Advertisements

Single Source Shortest Paths
§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 9 Prepared by İnanç TAHRALI.
COL 106 Shweta Agrawal and Amit Kumar
Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Advanced Data structure
CSC 2300 Data Structures & Algorithms April 13, 2007 Chapter 9. Graph Algorithms.
The selfish-edges Shortest-Path problem. The selfish-edges SP problem Input: an undirected graph G=(V,E) such that each edge is owned by a distinct selfish.
October 31, Algorithms and Data Structures Lecture XIII Simonas Šaltenis Nykredit Center for Database Research Aalborg University
1 Theory I Algorithm Design and Analysis (10 - Shortest paths in graphs) T. Lauer.
CSE 101- Winter ‘15 Discussion Section January 26th 2015.
CSCI 3160 Design and Analysis of Algorithms Tutorial 2 Chengyu Lin.
1 Greedy 2 Jose Rolim University of Geneva. Algorithmique Greedy 2Jose Rolim2 Examples Greedy  Minimum Spanning Trees  Shortest Paths Dijkstra.
CPSC 411, Fall 2008: Set 9 1 CPSC 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Fall 2008.
CS 315 March 24 Goals: Heap (Chapter 6) priority queue definition of a heap Algorithms for Insert DeleteMin percolate-down Build-heap.
1 8-ShortestPaths Shortest Paths in a Graph Fundamental Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Graph Algorithms: Shortest Path We are given a weighted, directed graph G = (V, E), with weight function w: E R mapping.
Instructors: C. Y. Tang and J. S. Roger Jang All the material are integrated from the textbook "Fundamentals of Data Structures in C" and some supplement.
Fibonacci Heaps. Single Source All Destinations Shortest Paths
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Dijkstra’s Algorithm Slide Courtesy: Uwash, UT 1.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
Heapsort CIS 606 Spring Overview Heapsort – O(n lg n) worst case—like merge sort. – Sorts in place—like insertion sort. – Combines the best of both.
1 Heaps Chapter 6 in CLRS. 2 Motivation Router: Dijkstra’s algorithm for single source shortest path Prim’s algorithm for minimum spanning trees.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 11 Tuesday, 12/4/01 Advanced Data Structures Chapters.
Chapter 9: Graphs Spanning Trees Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
1 Binomial heaps, Fibonacci heaps, and applications.
Week -7-8 Topic - Graph Algorithms CSE – 5311 Prepared by:- Sushruth Puttaswamy Lekhendro Lisham.
1 WEEK 9-10 Graphs II Unweighted Shortest Paths Dijkstra’s Algorithm Graphs with negative costs Acyclic Graphs Izmir University of Economics.
Dijkstras Algorithm Named after its discoverer, Dutch computer scientist Edsger Dijkstra, is an algorithm that solves the single-source shortest path problem.
1 Fibonacci heaps, and applications. 2 Yet a better MST algorithm (Fredman and Tarjan) Iteration i: We grow a forest, tree by tree, as follows. Start.
Binomial heaps, Fibonacci heaps, and applications
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
All-Pairs Shortest Paths & Essential Subgraph 01/25/2005 Jinil Han.
WEEK 3 Leftist Heaps CE222 Dr. Senem Kumova Metin CE222_Dr. Senem Kumova Metin.
Shortest Path in Weighted Graph : Dijkstra’s Algorithm.
The single-source shortest path problem (SSSP) input: a graph G = (V, E) with edge weights, and a specific source node s. goal: find a minimum weight (shortest)
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
The Shortest-Path problem in graphs with selfish-edges.
En tropy as Computational Complexity Computer Science Replugged Tadao Takaoka Department of Computer Science University of Canterbury Christchurch, New.
CS223 Advanced Data Structures and Algorithms 1 Priority Queue and Binary Heap Neil Tang 02/09/2010.
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
Fibonacci Heaps. Analysis FibonacciAnalysis.ppt Video  iew/cop5536sahni
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
1 Fibonacci heaps: idea List of multiway trees which are all heap-ordered. Definition: A tree is called heap-ordered if the key of each node is greater.
Fibonacci Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
Proof of correctness of Dijkstra’s algorithm: Basically, we need to prove two claims. (1)Let S be the set of vertices for which the shortest path from.
CSE 373: Data Structures and Algorithms Lecture 21: Graphs V 1.
Shortest Path -Prim’s -Djikstra’s. PRIM’s - Minimum Spanning Tree -A spanning tree of a graph is a tree that has all the vertices of the graph connected.
Fibonacci Heaps. Fibonacci Binary insert O(1) O(log(n)) find O(1) N/A union O(1) N/A minimum O(1) O(1) decrease key O(1) O(log(n)) delete O(log(n) O(log(n))
ליאור שפירא, חיים קפלן וחברים
Binomial heaps, Fibonacci heaps, and applications
CS 3343: Analysis of Algorithms
Priority Queues MakeQueue create new empty queue
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures and may also be used to do an increase key in a min structure (remove.
CSE 373: Data Structures and Algorithms
ערמות בינומיות ופיבונצ'י
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures.
Slide Courtesy: Uwash, UT
CMSC 341 Lecture 19.
CSE 373 Data Structures and Algorithms
Slide Courtesy: Uwash, UT
CSC 380: Design and Analysis of Algorithms
Graph Algorithms: Shortest Path
Implementation of Dijkstra’s Algorithm
Binomial heaps, Fibonacci heaps, and applications
CS 6310 Advanced Data Structure Wei-Shian Wang
Chapter 9: Graphs Spanning Trees
Presentation transcript:

by Amber McKenzie and Laura Boccanfuso

Dijkstra’s Algorithm Question: How do you know that Dijkstra’s algorithm finds the shortest path and is optimal when implemented with the Fibonacci heap?

Single-Source Shortest Path  For a given vertex, determine the shortest path between that vertex and every other vertex, i.e. minimum spanning tree.

Premise of Dijkstra’s Algorithm  First, finds the shortest path from the vertex to the nearest vertex.  Then, finds the shortest path to the next nearest vertex, and so on.  These vertices, for which the shortest paths have been found, form a subtree.  Thus, the next nearest vertex must be among the vertices that are adjacent to those in the subtree; these next nearest vertices are called fringe vertices.

Premise cont.  The fringe vertices are maintained in a priority queue which is updated with new distances from the source vertex at every iteration.  A vertex is removed from the priority queue when it is the vertex with the shortest distance from the source vertex of those fringe vertices that are left.

Pseudocode for every vertex v in V do d v ← ∞; p v ← null Insert(Q, v, d v ) //initialize vertex priority in the priority queue d s ← 0; Decrease(Q, s, d s ) //update priority of s with d s V T ← Ø for i ← 0 to |V| - 1 do u* ← DeleteMin(Q) //delete the minimum priority element V T ← V t U {u*} for every vertex u in V – V T that is adjacent to u* do if d u* + w(u*, u) < d u d u ← d u* + w(u*, u); p u ← u* Decrease(Q, u, d u )

Dijkstra’s Algorithm a d c b f e

a d c b f e a(-, 0) Tree verticesRemaining vertices b(a, 2) c(a, 5) d(a, 8) e(-, ∞) f(-, ∞)

Dijkstra’s Algorithm a d c b f e b(a, 2) Tree verticesRemaining vertices c(b, 2+2) d(a, 8) e(-, ∞ ) f(b, 2+6)

Dijkstra’s Algorithm a d c b f e c(b, 4) Tree verticesRemaining vertices d(a, 8) e(c, 4+1) f(b, 8)

Dijkstra’s Algorithm a d c b f e e(c, 5) Tree verticesRemaining vertices d(a, 8) f(b, 8)

Dijkstra’s Algorithm a d c b f e d(a, 8) Tree verticesRemaining vertices f(b, 8)

Dijkstra’s Algorithm a d c b f e

Dijkstra’s Algorithm: Priority Queue Tree verticesRemaining vertices a(-, 0)b(a, 2) c(a, 5) d(a, 8) e(-, ∞) f(-, ∞) b(a, 2)c(b, 2+2) d(a, 8) e(-, ∞ ) f(b, 2+6) c(b, 4)d(a, 8) e(c, 4+1) f(b, 8) e(c, 5)d(a, 8) f(b, 8) d(a, 8)f(b, 8) f(b, 8)

Fibonacci Heap Implementation  Manipulation of heap/queue  Time complexity efficiency What makes the Fibonacci Heap optimally suited for implementing the Dijkstra algorithm?

Fibonacci Heap Implementation Manipulation of heap/queue  Insert operation: creates a new heap with one element then performs a merge  Merge operation: concatenate the lists of tree roots of the two heaps  Decrease_key: take the node, decrease the key and reorder nodes if necessary, mark node or cut (if smaller than parent)  Delete_min: take root of min element and remove; decrease number of roots by linking together ones with same degree, check each remaining node to find minimum and delete

Fibonacci Heap Implementation OperationUSDL List* 2-3 tree HeapBinomialFibonacci make O (1) empty O( 1 ) insert O( 1 )O( logn ) O( 1 ) find_min O( n )O( logn )O (1) O( logn )O( 1 ) delete_min O( n )O( logn ) delete O( 1 )O( logn ) merge O( 1 )O(n) O( logn )O( 1 ) decrease_key O( 1 )O( logn ) O( 1 ) * USDL list: Unsorted Doubly Linked list Time Complexity Efficiency

Worst-case complexity  Formula to discover the worst-case complexity for Dijkstra’s algorithm: W(n,m) = O(n * cost of insert + n * cost of delete_min + m * cost of decrease_key) (Where n = maximum size of priority queue m = number of times inner loop is performed)

Worst-case complexity (cont.)  Unsorted linked list: W(n,m) = O(n* 1 + n * n + m * 1) = O(n 2 )  2-3 Tree : W(n,m) = O(n * logn + n * logn + m * logn) = O(mlogn)  Fibonacci Heap: W(n,m) = O(n * 1 + n * logn + m * 1) = O(nlogn + m)

Optimality of Dijkstra’s Algorithm  Adversary argument  In this case, it is the argument that there exists a path between the source vertex s and the target vertex t that is shorter than the path already determined by the algorithm. st

Adversary Argument  Since we have already determined the shortest paths to all the previous vertices that are now in the tree, this must mean that the path from s to t goes through some other vertex v whose distance from s has yet to be determined (meaning it is still in the priority queue). st v

Adversary Argument Cont.  The catch is that if this other vertex v through which t passes is still in the priority queue, then its distance to s is longer than that of all other vertices already in the tree.  Thus it cannot be a shorter distance than that which is already determined between s and t. st v

References  “ Algorithms and Data Structures Design, Correctness and Analysis” Jeffrey H. Kingston  “ A Result on the Computational Complexity of Heuristic Estimates for the A* Algorithm” Marco Valtorta  “ The Design & Analysis of Algorithms” Anany Levitin  Animation