Richard Anderson Lecture 9 Dijkstra’s algorithm

Slides:



Advertisements
Similar presentations
Data Structures and Algorithms Graphs Single-Source Shortest Paths (Dijkstra’s Algorithm) PLSD210(ii)
Advertisements

1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
CSC 213 Lecture 23: Shortest Path Algorithms. Weighted Graphs Each edge in weighted graph has numerical weight Weights can be distances, building costs,
CSE 421 Algorithms Richard Anderson Dijkstra’s algorithm.
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
Dijkstra’s Shortest Paths CS 312 Lecture 4. Announcements Project 1 comes out Friday –Min spanning trees and scheduling –due 2 weeks from Friday (1 week.
Lecture 24 CSE 331 Oct 30, Homework stuff Please turn in your HW 6 Graded HW 5 and HW 7 at the END of the lecture.
Lecture 27 CSE 331 Nov 3, Combining groups Groups can unofficially combine in the lectures.
Lecture 25 CSE 331 Nov 2, Adding teeth to group talk Form groups of size at most six (6) Pick a group leader I will ask group leader(s) to come.
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
Dijkstra’s Algorithm. 2 Shortest-path Suppose we want to find the shortest path from node X to node Y It turns out that, in order to do this, we need.
Introduction to Algorithms Jiafen Liu Sept
Lecture 23 CSE 331 Oct 24, Reminder 2 points for Piazza participation 3 points for mini-project.
1 Introduction to Algorithms L ECTURE 17 (Chap. 24) Shortest paths I 24.2 Single-source shortest paths 24.3 Dijkstra’s algorithm Edsger Wybe Dijkstra
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 3.
CSE 421 Algorithms Richard Anderson Lecture 8 Optimal Caching Dijkstra’s algorithm.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 10.
CSE 421 Algorithms Richard Anderson Lecture 21 Shortest Paths and Network Flow.
Lecture 23 CSE 331 Oct 26, 2016.
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Autumn 2016 Lecture 11 Minimum Spanning Trees (Part II)
Autumn 2015 Lecture 11 Minimum Spanning Trees (Part II)
Autumn 2016 Lecture 9 Dijkstra’s algorithm
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
CSE 332: Data Structures Disjoint Set Union/Find
Autumn 2015 Lecture 9 Dijkstra’s algorithm
Lecture 24 CSE 331 Oct 25, 2013.
Lecture 22 CSE 331 Oct 23, 2017.
Lecture 23 CSE 331 Oct 25, 2017.
Lecture 24 CSE 331 Oct 29, 2012.
Lecture 23 CSE 331 Oct 24, 2011.
Richard Anderson Lecture 9 Dijkstra’s algorithm
Lecture 22 CSE 331 Oct 24, 2016.
Autumn 2015 Lecture 10 Minimum Spanning Trees
Richard Anderson Lecture 21 Network Flow
Richard Anderson Lecture 21 Shortest Paths
Shortest path algorithm
Richard Anderson Lecture 6 Greedy Algorithms
Route Inspection Which of these can be drawn without taking your pencil off the paper and without going over the same line twice? If we introduce a vertex.
Richard Anderson Autumn 2016 Lecture 7
Richard Anderson Lecture 10 Minimum Spanning Trees
Lecture 22 CSE 331 Oct 15, 2014.
Richard Anderson Lecture 7 Greedy Algorithms
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Chapter 24: Single-Source Shortest Paths
Single Source Shortest Paths Dijkstra’s Alg. (no negative lengths!)
Lecture 24 CSE 331 Oct 24, 2014.
Autumn 2016 Lecture 10 Minimum Spanning Trees
CSE332: Data Abstractions Lecture 17: Shortest Paths
Lecture 6 Shortest Path Problem.
Lecture 23 CSE 331 Oct 24, 2011.
Winter 2019 Lecture 9 Dijkstra’s algorithm
Lecture 26 CSE 331 Nov 1, 2010.
Chapter 24: Single-Source Shortest Paths
CSE 417: Algorithms and Computational Complexity
Implementation of Dijkstra’s Algorithm
Richard Anderson Winter 2019 Lecture 7
Dijkstra Algorithm examples
Richard Anderson Lecture 20 Shortest Paths and Network Flow
Winter 2019 Lecture 10 Minimum Spanning Trees
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Richard Anderson Lecture 22 Network Flow
Data Structures and Algorithm Analysis Lecture 8
More Graphs Lecture 19 CS2110 – Fall 2009.
Richard Anderson Autumn 2019 Lecture 7
Lecture 24 CSE 331 Oct 29, 2018.
Autumn 2019 Lecture 9 Dijkstra’s algorithm
Presentation transcript:

Richard Anderson Lecture 9 Dijkstra’s algorithm CSE 421 Algorithms Richard Anderson Lecture 9 Dijkstra’s algorithm

Who was Dijkstra? What were his major contributions?

Edsger Wybe Dijkstra http://www.cs.utexas.edu/users/EWD/

Single Source Shortest Path Problem Given a graph and a start vertex s Determine distance of every vertex from s Identify shortest paths to each vertex Express concisely as a “shortest paths tree” Each vertex has a pointer to a predecessor on shortest path 1 u u 1 2 3 5 s x s x 4 3 3 v v

Construct Shortest Path Tree from s 2 d d 1 a a 5 4 4 4 e e -3 c c s -2 s 3 3 2 6 g g b b 3 7 f f

Warmup If P is a shortest path from s to v, and if t is on the path P, the segment from s to t is a shortest path between s and t WHY? (submit an answer) v t s

Careful Proof Suppose s-v is a shortest path Suppose s-t is not a shortest path Therefore s-v is not a shortest path Therefore s-t is a shortest path

Prove if s-t not a shortest path then s-v is not a shortest path

Dijkstra’s Algorithm S = {}; d[s] = 0; d[v] = inf for v != s While S != V Choose v in V-S with minimum d[v] Add v to S For each w in the neighborhood of v d[w] = min(d[w], d[v] + c(v, w) 4 3 y 1 1 u 1 1 4 s x 2 2 2 2 v 2 3 5 z

Simulate Dijkstra’s algorithm (strarting from s) on the graph Vertex Added 1 Round s a b c d c a 1 1 2 3 4 5 3 2 1 s 4 4 6 1 b d 3

Dijkstra’s Algorithm as a greedy algorithm Elements committed to the solution by order of minimum distance

Correctness Proof Elements in S have the correct label Key to proof: when v is added to S, it has the correct distance label. y x s u v

Proof Let Pv be the path of length d[v], with an edge (u,v) Let P be some other path to v. Suppose P first leaves S on the edge (x, y) P = Psx + c(x,y) + Pyv Len(Psx) + c(x,y) >= d[y] Len(Pyv) >= 0 Len(P) >= d[y] + 0 >= d[v] y x s u v

Negative Cost Edges Draw a small example a negative cost edge and show that Dijkstra’s algorithm fails on this example

Bottleneck Shortest Path Define the bottleneck distance for a path to be the maximum cost edge along the path u 6 5 s x 2 5 4 3 v

Compute the bottleneck shortest paths 6 d d 6 a a 5 4 4 4 e e -3 c c s -2 s 3 3 2 6 g g b b 4 7 f f

How do you adapt Dijkstra’s algorithm to handle bottleneck distances Does the correctness proof still apply?