Lecture 6 Shortest Path Problem.

Slides:



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

Lecture 6 Shortest Path Problem. s t Dynamic Programming.
 2004 SDU Lecture9- Single-Source Shortest Paths 1.Related Notions and Variants of Shortest Paths Problems 2.Properties of Shortest Paths and Relaxation.
Chapter 5 Shortest Paths: Label-Correcting Algorithms
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Shortest Paths Definitions Single Source Algorithms –Bellman Ford –DAG shortest path algorithm –Dijkstra All Pairs Algorithms –Using Single Source Algorithms.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
CMPE 150- Introduction to Computer Networks 1 CMPE 150 Fall 2005 Lecture 21 Introduction to Computer Networks.
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck.
Graphs – Shortest Path (Weighted Graph) ORD DFW SFO LAX
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Spring 2015 Lecture 10: Elementary Graph Algorithms
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Lecture 7 All-Pairs Shortest Paths. All-Pairs Shortest Paths.
Minimum spanning trees (MST) Def: A spanning tree of a graph G is an acyclic subset of edges of G connecting all vertices in G. A sub-forest of G is an.
CSE 2331 / 5331 Topic 12: Shortest Path Basics Dijkstra Algorithm Relaxation Bellman-Ford Alg.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
CS38 Introduction to Algorithms Lecture 10 May 1, 2014.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
15.082J & 6.855J & ESD.78J September 30, 2010 The Label Correcting Algorithm.
Graphs + Shortest Paths David Kauchak cs302 Spring 2013.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Introduction to Algorithms
Main algorithm with recursion: We’ll have a function DFS that initializes, and then calls DFS-Visit, which is a recursive function and does the depth first.
Shortest Path 6/18/2018 4:22 PM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Lecture 13 Shortest Path.
Lecture 5 Dynamic Programming
Richard Anderson Lecture 29 NP-Completeness and course wrap-up
CSC317 Graph algorithms Why bother?
CSE 2331/5331 Topic 9: Basic Graph Alg.
Lecture 5 Dynamic Programming
More Graph Algorithms.
Lecture 7 All-Pairs Shortest Paths
Edmonds-Karp Algorithm
15.082J & 6.855J & ESD.78J Visualizations
15.082J & 6.855J & ESD.78J Visualizations
Lecture 6 Shortest Path Problem.
Algorithms (2IL15) – Lecture 5 SINGLE-SOURCE SHORTEST PATHS
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Graph Representation (23.1/22.1)
Richard Anderson Lecture 9 Dijkstra’s algorithm
Algorithms and Data Structures Lecture XIII
Autumn 2015 Lecture 10 Minimum Spanning Trees
Richard Anderson Autumn 2016 Lecture 5
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Autumn 2016 Lecture 10 Minimum Spanning Trees
Advanced Algorithms Analysis and Design
Sorting and Divide-and-Conquer
Dijkstra’s Algorithm for Shortest Paths
and 6.855J Dijkstra’s Algorithm
Visualizations Dijkstra’s Algorithm
and 6.855J Topological Ordering
CSE 417: Algorithms and Computational Complexity
Implementation of Dijkstra’s Algorithm
Algorithms CSCI 235, Spring 2019 Lecture 35 Graphs IV
Lecture 12 Shortest Path.
Richard Anderson Lecture 5 Graph Theory
Prim’s algorithm for minimum spanning trees
Winter 2019 Lecture 10 Minimum Spanning Trees
Chapter 24: Single-Source Shortest-Path
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Advanced Algorithms Analysis and Design
15.082J & 6.855J & ESD.78J Visualizations
Data Structures and Algorithm Analysis Lecture 8
Presentation transcript:

Lecture 6 Shortest Path Problem

Quiz Sample True or False Every dynamic programming can be analyzed with formula: Run-time = (table size) x (computation time of recursive formula). Answer: False A counterexample can be seen in study of the shortest path problem.

s t

Dynamic Programming

Dynamic Programming

Dynamic Programming

Lemma Proof

Theorem 2 -1 -1 1 2

Counterexample

Quiz Sample True or false? Every algorithm of dynamic-programming type can use the following formula to estimate its running time: running time = (table size) x (computing time for recursive formula).

Running Time Is above calculation correct?

Running Time Is above calculation correct?

Smart Implementation

Running Time how much time do we need?

Running Time how much time do we need? A topological ordering is an ordering of nodes such that for any edge (u,v), u is put before v.

Topological Sort (Kahn)

An Example 4 2 4 2 2 1 2 3 1 1 6 4 2 3 3 5

An Example 4 2 4 2 1 2 3 1 1 6 2 3 3 5

An Example 4 2 4 2 1 2 3 1 1 6 2 3 3 5

An Example 2 4 2 3 1 1 6 2 3 3 5

An Example 2 4 2 3 1 1 6 2 3 3 5

An Example 2 4 2 3 1 1 6 2 3 5

An Example 2 4 2 3 1 1 6 2 3 5

An Example 2 4 2 1 1 6 3 5

An Example 2 4 2 3 1 1 6 2 3 5

Topological Sort (Kahn)

Smart Implementation

Theorem Dynamic Programming is a linear time algorithm for the shortest path problem in acyclic networks, possibly with negative weight. total running time O(m+n).

An Example      Initialize 4 2 4 2 2 1 2 3 1  1 6 4 2 3 3 5   Initialize Select the node with the minimum temporary distance label.

Update Step 2   4 2 4 2 2 1 2 3  1 6 4 2 3 3 5   4

Choose u such that D(u)=Ǿ 2  4 2 4 2 2 1 2 3  1 6 4 2 3 3 5  4

Update Step 6 2    4 4 3 The predecessor of node 3 is now node 2 4 1 2 3  1 6 4 2 3 3 5  4 4 3 The predecessor of node 3 is now node 2

Choose u Such That N_(u) S 2 6 4 2 4 2 2 1 2 3  1 6 4 2 3 3 5 3 4

Update 2 6 4 2 4 2 2 1 2 3  1 6 4 2 3 3 5 3 4 d(5) is not changed.

Choose u s.t . N_(u) S 2 6 4 2 4 2 2 1 2 3  1 6 4 2 3 3 5 3 4

Update 2 6 4 2 4 2 2 6 1 2 3  1 6 4 2 3 3 5 3 4 d(4) is not changed

Choose u s.t. N_(u) S 2 6 4 2 4 2 2 1 2 3 6 1 6 4 2 3 3 5 3 4

Update 2 6 4 2 4 2 2 1 2 3 6 1 6 4 2 3 3 5 3 4 d(6) is not updated

Choose u s.t. N_(u) S 2 6 6 3 4 There is nothing to update 4 2 4 2 2 1 1 2 3 6 1 6 4 2 3 3 5 3 4 There is nothing to update

End of Algorithm 2 6 6 3 4 All nodes are now permanent 1 2 3 6 1 6 4 2 3 3 5 3 4 All nodes are now permanent The predecessors form a tree The shortest path from node 1 to node 6 can be found by tracing back predecessors

Theorem Dynamic Programming is a linear time algorithm for the shortest path problem in acyclic networks, possibly with negative weight. Corollary. In acyclic networks, the longest path can be computed in linear time. (QE 2015F) Why?