Single Source Shortest Path
|
|
- Ilene Gray
- 5 years ago
- Views:
Transcription
1 Single Source Shortest Path A directed graph G = (V, E) and a pair of nodes s, d is given. The edges have a real-valued weight W i. This time we are looking for the weight and the shortest path from s to d. The weight of the shortest path from s to d is called δ(s, d). We still have the property that a shortest path between u and v contains shortest path between intermediate nodes. The shortest path between s and d might not be defined if the graph contains cycles with negative weight. A shortest path can not contain s positive weight cycle. Hence, path length is at most n 1. SSSP 1
2 Shortest Path Tree A shortest path tree G = (V, E ) is a directed subgraph of G (V V and E E), such that 1. V is the set of nodes reachable from s in G. 2. G forms a rooted tree with root s, and 3. For all v V, the unique simple path from s to v in G is a shortest path from s to v in G. Shortest paths and shortest path trees are not unique! SSSP 2
3 Relaxation For each vertex v V we maintain an attribute d[v], which is an upper bound on the weight of a shortest path from source s to v. The attribute is called shortest path estimate. In the beginning, d[v] = for v s and d[s] = 0. We also use variables π[v] storing the predecessor of v. In a relaxation step we may decrease the shortest path estimate and update the π values. SSSP 3
4 Relaxation (u, v, w) If d[v] > d[u] + w[u, v], then d[v] := d[u] + w(u, v) and π[v] = u The path that uses u as a last edge is shorter than the one we found previously. Bellman-Ford(G, w, s) Initialise-Single-Source(G, s) for i 1 to V [G] 1 do for each edge (u, v) E[G] do Relax(u, v, w) for each edge (u, v) E[G] do if d[v] > d[u] + w(u, v) then return False return True SSSP 4
5 Runtime and Correctness The runtime is easy. In every iteration of the for-loop we relax every edge. We need V 1 passes over all edges. This gives a runtime of O(V E). First we show the following: if there are no negative-weight cycles, the algorithm computes correct shortest path weights for all vertices reachable from s. But to do that we need a couple of other results,... Lemma 1 Let G = (V, E) be a weighted directed graph with source s and weight function w : E R, and assume that G contains no negative-weight cycle that is reachable from s. Then, after V 1 iterations of the first for-loop of the Bellman-Ford, we have d[v] = δ(s, v) for all vertices v that are reachable from s. SSSP 5
6 Upper bound property Lemma 2 Let G = (V, E) be a weighted, directed graph with weight function w : E R, and let s V be a source vertex. Assume G is initialised as we defined. Then d[v] δ(s, v) for all v V, and this invariant is maintained over any sequence of relaxation steps. Moreover, once d[v] achieves its lower bound δ(s, v), it never changes. SSSP 6
7 Proof of Lemma 2 We prove the invariant d[v] δ(s, v) by induction over the number of relaxation steps. After the in initialisation d[v] δ(s, v) is certainly true. For the inductive step, consider the relaxation of an edge (u, v). By the inductive hypothesis, d[x] δ(s, x) for all x V prior to the relaxation. If d[v] changes we have d[v] = d[u] + w(u, v) δ(s, u) + w(u, v) δ(s, v). To see that the value of d[v] never changes once d[v] = δ(s, v) have a look at the above equations again. We have just shown d[v] δ(s, v). It can not increase since relaxation steps do not increase values. SSSP 7
8 Lemma 3: Convergence property Let G = (V, E) be a weighted, directed graph with weight function w : E R, and let s V be a source vertex. Let s = u v be a shortest path in G for some vertices u, v V. Suppose that G is initialised as we defined. Then, a sequence of relaxation steps that includes the call RELAX(u, v, w) is executed on the edges of G. If 4d[u] = δ(s, u) at any time prior to the call, then d[v] = δ(s, v) at all times after the call. SSSP 8
9 Proof of Lemma 3 By the upper bound property: if d[u] = δ(s, u) at some point prior to relaxing edge (u, v), then this equality holds thereafter. After relaxing edge (u, v) we have we have d[v] d[u] + w(u, v) = δ(s, u) + w(u, v) = δ(s, v). The first inequality is due to the fact that, after relaxing edge (u, v), we have d[v] d[u] + w(u, v). The last equality is due to the fact that subpath of shortest path are also shortest paths. By the upper bound property, d[v] δ(s, v), from which we can conclude that d[v] = δ(s, v), and this equality is maintained thereafter. SSSP 9
10 Path-relaxation Property Lemma 4 Let G = (V, E) be a weighted, directed graph with weight function w : E R, and let s V be a source vertex. Consider any shortest path p = (v 1, v 2,..., v k ) from s = v 0 to v k. If G is initialised as we defined, and then a sequence of relaxation steps occurs that includes, in order, relaxations of the edges (v 0, v 1 ), (v 1, v 2 ),... (v k 1, v k ), then d[v k ] = δ(s, v k ). This holds no matter which other edge relaxations occur. SSSP 10
11 Proof of Lemma 4 We show by induction that after the ith edge of path p is relaxed, we have d[v i ] = δ(s, v i ). For the basis, i = 0 we have from the initialisation d[v 0 ] = d[s] = 0 = δ(s, s). By the upper bound property, the value of d[s] is never changes after initialisation. For the inductive step, we assume that d[v i 1 ] = δ(s, v i 1 ), and we examine the relation of edge (v i 1, v i ). By the convergence property, we have after the relation d[v i ] = δ(v, v i ). Again, this equality is maintained thereafter. SSSP 11
12 Proof of Lemma 1 Consider a vertex v that is reachable from s. Let p = (v 0, v 1,... v k ) (with v 0 = s and v k = v) be a shortest acyclic path from s to v. The path has at most V 1 edges, giving k V 1. Each of the iterations of the for loop relaxes all edges of E. Among the edges relaxed in the ith iteration we have the edge (v i 1, v i ). By the relaxation property we have d[v] = d[v k ] = δ(s, v k ) = δ(v, v) SSSP 12
13 Predecessor-subpath property Lemma 5 Let G = (V, E) be a weighted, directed graph with weight function w : E R, and let s V be a source vertex. Assume that G does not contain a negative cycle reachable from s. Then, if we execute relaxation steps resulting in d[v] = δ(s, v) for all v V. Then the predecessor subgraph G π is a shortest-path tree rooted at s. SSSP 13
14 Proof of Lemma 5 We have to show that all three shortest-paths tree properties hold. The vertices that are reachable from s are the ones with finite d[v]. A vertex v V {s} has s finite value d[v] if and only if π[v] nil. Thus, the vertices in V π are those reachable from s. Third property not here,... It remains to show that the unique path in G π are shortest paths. Let p = (s = v 0, v 1,... v k = v) be a path in G π. For i = 1, 2,... k we have both d[v i ] = δ(s, v i ) and d[v i ] d[v i 1 ] + w(v i 1, v i ). Hence, w(v i 1, v i ) δ(s, v i ) δ(s, v i 1 ). Summing the weights along p yields w(p) = k i=1 w(v i 1, v i ) k i=1 (δ(s, v i) δ(s, v i 1 ))) = δ(s, v k ) δ(s, v 0 ) = δ(s, v k ) SSSP 14
15 Thus, w(p) δ(s, v k ) and we can conclude w(p) = δ(s, v k ) since δ(s, v k ) is a lower bound. p is a shortest path. SSSP 15
16 Correctness of Bellman-Ford Lemma 6 Let G = (V, E) be a weighted, directed graph with weight function w : E R, and let s V be a source vertex. Consider any shortest path p = (v 1, v 2,..., v k ) from s = v 0 to v k. 1. If G contains no negative cycles that are reachable from s, then the algorithm returns true and we have d[v] = δ(s, v) for all vertices v V and the Bellman-Ford algorithm computes a shortest path tree rooted at s. 2. If G does contains a negative weight cycle reachable from s, then the algorithm returns false. SSSP 16
17 Proof of Lemma 6 Suppose the graph does not contain a negative cycle that is reachable for s. If a vertex v is reachable from s, then Lemma 1 shows that d[v] = δ(s, v). In v is not reachable from v, d[v] = δ(s, v) =. This follows from the upper-bound property since we always have = δ(u, v) d[v], Hence, we have d[v] =. The predecessor-subgraph property implies that G π is a shortest-path tree. It remains to show that the Bellman-Ford returns true. At termination we have for all edges (u, v) E d[v] = δ(s, v) δ(s, u) + w(u, v) = d[u] + w(u, v) SSSP 17
18 Proof of Lemma 6 cont Suppose the graph does contain a negative cycle c = (v 0, v 1,..., v k ) (v 0 = v k ) that is reachable for s. Assume for contradiction that Bellman-Ford returns true. Thus, d[v i ] d[v i 1 ] + w(v i 1, v i ) for 1 i k and k i=1 w(v i 1, v i ) < 0. k i=1 d[v i] k i=1 (d[v i 1] + w(v i 1, v i )) = k i=1 d[v i 1] + k i=1 w(v i 1, v i ). Each vertex appears exactly once in each of the above summations and k i=1 d[v i] = k i=1 d[v i 1]. This gives 0 < k i=1 w(v i 1, v i ) and a contradiction. SSSP 18
19 Dijkstra s Algorithm The algorithm solves the single-source shortest path problem for the case of non-negative edge weight. It maintains a set of vertices S whose final shortest path has already been determined. It repeatedly selects the vertex u V S with minimum shortest pats estimate adds it to S, and relaxes all edges leaving u. We will use a min-priority queue Q for the vertices, keyed by their d values. SSSP 19
20 Dijkstra s Algorithm Dijkstra(G, w, s) Initialise-Single-Source(G, s) S := and Q := V [G] while Q do u := Extract Min(Q) S := S {u} for each vertex v adjacent to u do Relax(u,v,w) SSSP 20
21 Idea of Dijkstra s Algorithm The algorithm maintains the invariant that Q = V S that holds at the start of each iteration of the while-loop. The invariant is certainly true at the beginning. Each time we go through the while loop, a vertex u is extracted from Q = V S and added to S. u has the smallest shortest path estimate d[u]. Then each outgoing edge (u, v) is relaxed. The shortest path estimate is updated if the shortest path to v can be improved by going through u. Because Dijkstra s algorithm always choses the lightest vertex to add to set S, it is a greedy strategy. Dijkstra calculates an optimal solution. SSSP 21
22 Idea of Dijkstra s Algorithm II The key of the correctness proof is to show that each time a vertex u is added to S we have d[u] = δ(s, u). The runtime is O((V + E) log V ). SSSP 22
Computer Science & Engineering 423/823 Design and Analysis of Algorithms
Computer Science & Engineering 423/823 Design and Analysis of Algorithms Lecture 07 Single-Source Shortest Paths (Chapter 24) Stephen Scott and Vinodchandran N. Variyam sscott@cse.unl.edu 1/36 Introduction
More informationShortest Path Problem
Shortest Path Problem CLRS Chapters 24.1 3, 24.5, 25.2 Shortest path problem Shortest path problem (and variants) Properties of shortest paths Algorithmic framework Bellman-Ford algorithm Shortest paths
More informationSingle Source Shortest Paths
Single Source Shortest Paths Given a connected weighted directed graph G(V, E), associated with each edge u, v E, there is a weight w(u, v). The single source shortest paths (SSSP) problem is to find a
More informationIntroduction. I Given a weighted, directed graph G =(V, E) with weight function
ntroduction Computer Science & Engineering 2/82 Design and Analysis of Algorithms Lecture 06 Single-Source Shortest Paths (Chapter 2) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu
More informationSingle Source Shortest Path (SSSP) Problem
Single Source Shortest Path (SSSP) Problem Single Source Shortest Path Problem Input: A directed graph G = (V, E); an edge weight function w : E R, and a start vertex s V. Find: for each vertex u V, δ(s,
More informationIntroduction. I Given a weighted, directed graph G =(V, E) with weight function
ntroduction Computer Science & Engineering 2/82 Design and Analysis of Algorithms Lecture 05 Single-Source Shortest Paths (Chapter 2) Stephen Scott (Adapted from Vinodchandran N. Variyam) sscott@cse.unl.edu
More informationLecture 11: Analysis of Algorithms (CS ) 1
Lecture 11: Analysis of Algorithms (CS583-002) 1 Amarda Shehu November 12, 2014 1 Some material adapted from Kevin Wayne s Algorithm Class @ Princeton 1 2 Dynamic Programming Approach Floyd-Warshall Shortest
More informationCOT 6405 Introduction to Theory of Algorithms
COT 6405 Introduction to Theory of Algorithms Topic 16. Single source shortest path 11/18/2015 1 Problem definition Problem: given a weighted directed graph G, find the minimum-weight path from a given
More informationCOMP251: Single source shortest paths
COMP51: Single source shortest paths Jérôme Waldispühl School of Computer Science McGill University Based on (Cormen et al., 00) Problem What is the shortest road to go from one city to another? Eample:
More informationChapter 24. Shortest path problems. Chapter 24. Shortest path problems. 24. Various shortest path problems. Chapter 24. Shortest path problems
Chapter 24. Shortest path problems We are given a directed graph G = (V,E) with each directed edge (u,v) E having a weight, also called a length, w(u,v) that may or may not be negative. A shortest path
More informationAlgorithms on Graphs: Part III. Shortest Path Problems. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..
.. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar.. Shortest Path Problems Algorithms on Graphs: Part III Path in a graph. Let G = V,E be a graph. A path p = e 1,...,e k, e i E,
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 20. Example. Shortest Paths Definitions
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 20 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University March 19, 2007 Last Time Minimum Spanning Trees Strongly
More informationfrom notes written mostly by Dr. Carla Savage: All Rights Reserved
CSC 505, Fall 2000: Week 9 Objectives: learn about various issues related to finding shortest paths in graphs learn algorithms for the single-source shortest-path problem observe the relationship among
More informationMinimum Spanning Trees
Minimum Spanning Trees Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting houses u and v has a repair cost w(u, v). Goal: Repair enough (and no
More information5.4 Shortest Paths. Jacobs University Visualization and Computer Graphics Lab. CH : Algorithms and Data Structures 456
5.4 Shortest Paths CH08-320201: Algorithms and Data Structures 456 Definitions: Path Consider a directed graph G=(V,E), where each edge e є E is assigned a non-negative weight w: E -> R +. A path is a
More informationGraphs. Part II: SP and MST. Laura Toma Algorithms (csci2200), Bowdoin College
Laura Toma Algorithms (csci2200), Bowdoin College Topics Weighted graphs each edge (u, v) has a weight denoted w(u, v) or w uv stored in the adjacency list or adjacency matrix The weight of a path p =
More information4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24
/8/11 Single-Source Shortest Path Chapter 1 Shortest Paths Finding the shortest path between two nodes comes up in many applications o Transportation problems o Motion planning o Communication problems
More information1 Dijkstra s Algorithm
Lecture 11 Dijkstra s Algorithm Scribes: Himanshu Bhandoh (2015), Virginia Williams, and Date: November 1, 2017 Anthony Kim (2016), G. Valiant (2017), M. Wootters (2017) (Adapted from Virginia Williams
More informationCOL 702 : Assignment 1 solutions
COL 70 : Assignment 1 solutions 1(a ( n T (n = T + bn log n ( n = T + b n ( n log + bn log n ( n = T + b n ( n 8 log + b n log ( n + bn log n = bn log n + b n log n + bn log n +... log n terms = nb [(log
More information22 Elementary Graph Algorithms. There are two standard ways to represent a
VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph
More informationIntroduction to Algorithms. Lecture 11
Introduction to Algorithms Lecture 11 Last Time Optimization Problems Greedy Algorithms Graph Representation & Algorithms Minimum Spanning Tree Prim s Algorithm Kruskal s Algorithm 2 Today s Topics Shortest
More informationDijkstra s Shortest Path Algorithm
Dijkstra s Shortest Path Algorithm DPV 4.4, CLRS 24.3 Revised, October 23, 2014 Outline of this Lecture Recalling the BFS solution of the shortest path problem for unweighted (di)graphs. The shortest path
More informationOutline. (single-source) shortest path. (all-pairs) shortest path. minimum spanning tree. Dijkstra (Section 4.4) Bellman-Ford (Section 4.
Weighted Graphs 1 Outline (single-source) shortest path Dijkstra (Section 4.4) Bellman-Ford (Section 4.6) (all-pairs) shortest path Floyd-Warshall (Section 6.6) minimum spanning tree Kruskal (Section 5.1.3)
More informationShortest path problems
Next... Shortest path problems Single-source shortest paths in weighted graphs Shortest-Path Problems Properties of Shortest Paths, Relaxation Dijkstra s Algorithm Bellman-Ford Algorithm Shortest-Paths
More informationPart VI Graph algorithms. Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths
Part VI Graph algorithms Chapter 22 Elementary Graph Algorithms Chapter 23 Minimum Spanning Trees Chapter 24 Single-source Shortest Paths 1 Chapter 22 Elementary Graph Algorithms Representations of graphs
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming and data-structures CS/ENGRD 20 SUMMER 208 Lecture 3: Shortest Path http://courses.cs.cornell.edu/cs20/208su Graph Algorithms Search Depth-first search Breadth-first search
More informationTheory of Computing. Lecture 7 MAS 714 Hartmut Klauck
Theory of Computing Lecture 7 MAS 714 Hartmut Klauck Shortest paths in weighted graphs We are given a graph G (adjacency list with weights W(u,v)) No edge means W(u,v)=1 We look for shortest paths from
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 6 Greedy Graph Algorithms Shortest paths Adam Smith 9/8/14 The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle Does
More informationShortest Paths. Nishant Mehta Lectures 10 and 11
Shortest Paths Nishant Mehta Lectures 0 and Communication Speeds in a Computer Network Find fastest way to route a data packet between two computers 6 Kbps 4 0 Mbps 6 6 Kbps 6 Kbps Gbps 00 Mbps 8 6 Kbps
More informationShortest Paths. Nishant Mehta Lectures 10 and 11
Shortest Paths Nishant Mehta Lectures 0 and Finding the Fastest Way to Travel between Two Intersections in Vancouver Granville St and W Hastings St Homer St and W Hastings St 6 Granville St and W Pender
More informationBreadth-First Search, 1. Slides for CIS 675 DPV Chapter 4. Breadth-First Search, 3. Breadth-First Search, 2
Breadth-First Search, Slides for CIS DPV Chapter Jim Royer EECS October, 00 Definition In an undirected graph, the distance between two vertices is the length of the shortest path between them. (If there
More informationUnit 5F: Layout Compaction
Course contents Unit 5F: Layout Compaction Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 5F 1 Design rules: restrictions on the mask patterns to increase the probability
More informationUnit 3: Layout Compaction
Unit 3: Layout Compaction Course contents Design rules Symbolic layout Constraint-graph compaction Readings: Chapter 6 Unit 3 1 Design rules: restrictions on the mask patterns to increase the probability
More informationOutline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths
Outline Computer Science 33 Computation of Minimum-Cost Paths Dijkstra s Mike Jacobson Department of Computer Science University of Calgary Lecture #34 Dijkstra s to Find Min-Cost Paths 3 Example 4 5 References
More informationCS 341: Algorithms. Douglas R. Stinson. David R. Cheriton School of Computer Science University of Waterloo. February 26, 2019
CS 341: Algorithms Douglas R. Stinson David R. Cheriton School of Computer Science University of Waterloo February 26, 2019 D.R. Stinson (SCS) CS 341 February 26, 2019 1 / 296 1 Course Information 2 Introduction
More informationIntroductory Computer Programming: Shortest Path Algorithms
Introductory Computer Programming: 2017-18 Shortest Path Algorithms Soumik Purkayastha MD-1710 Contents 1 Project Proposal 1 2 Report 3 2.1 Introduction........................................ 3 2.2 Basic
More informationDijkstra s Algorithm
Dijkstra s Algorithm 7 1 3 1 Weighted Graphs In a weighted graph, each edge has an associated numerical value, called the weight of the edge Edge weights may represent, distances, costs, etc. Example:
More informationUnit 2: Algorithmic Graph Theory
Unit 2: Algorithmic Graph Theory Course contents: Introduction to graph theory Basic graph algorithms Reading Chapter 3 Reference: Cormen, Leiserson, and Rivest, Introduction to Algorithms, 2 nd Ed., McGraw
More informationLecture I: Shortest Path Algorithms
Lecture I: Shortest Path Algorithms Dr Kieran T. Herley Department of Computer Science University College Cork October 201 KH (21/10/1) Lecture I: Shortest Path Algorithms October 201 1 / 28 Background
More informationShortest Paths. Shortest Path. Applications. CSE 680 Prof. Roger Crawfis. Given a weighted directed graph, one common problem is finding the shortest
Shortest Path Introduction to Algorithms Shortest Paths CS 60 Prof. Roger Crawfis Given a weighted directed graph, one common problem is finding the shortest path between two given vertices Recall that
More information09 B: Graph Algorithms II
Correctness and Complexity of 09 B: Graph Algorithms II CS1102S: Data Structures and Algorithms Martin Henz March 19, 2010 Generated on Thursday 18 th March, 2010, 00:20 CS1102S: Data Structures and Algorithms
More informationMinimum Spanning Tree
Minimum Spanning Tree 1 Minimum Spanning Tree G=(V,E) is an undirected graph, where V is a set of nodes and E is a set of possible interconnections between pairs of nodes. For each edge (u,v) in E, we
More informationWeek 12: Minimum Spanning trees and Shortest Paths
Agenda: Week 12: Minimum Spanning trees and Shortest Paths Kruskal s Algorithm Single-source shortest paths Dijkstra s algorithm for non-negatively weighted case Reading: Textbook : 61-7, 80-87, 9-601
More informationAlgorithm Design, Anal. & Imp., Homework 4 Solution
Algorithm Design, Anal. & Imp., Homework 4 Solution Note: The solution is for your personal use for this course. You are not allowed to post the solution in public place. There could be mistakes in the
More information22 Elementary Graph Algorithms. There are two standard ways to represent a
VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph
More informationShortest Path Algorithms
Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E
More informationCS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14
CS200: Graphs Rosen Ch. 9.1-9.4, 9.6, 10.4-10.5 Walls and Mirrors Ch. 14 Trees as Graphs Tree: an undirected connected graph that has no cycles. A B C D E F G H I J K L M N O P Rooted Trees A rooted tree
More informationDesign and Analysis of Algorithms 演算法設計與分析. Lecture 13 December 18, 2013 洪國寶
Design and Analysis of Algorithms 演算法設計與分析 Lecture 13 December 18, 2013 洪國寶 1 Homework #10 1. 24.1-1 (p. 591 / p. 654) 2. 24.1-6 (p. 592 / p. 655) 3. 24.3-2 (p. 600 / p. 663) 4. 24.3-8 (p. 601) / 24.3-10
More information6.006 Introduction to Algorithms Spring 2008
MIT OpenCourseWare http://ocw.mit.edu 6.006 Introduction to Algorithms Spring 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Introduction to Algorithms:
More information2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.
1. T F: Consider a directed graph G = (V, E) and a vertex s V. Suppose that for all v V, there exists a directed path in G from s to v. Suppose that a DFS is run on G, starting from s. Then, true or false:
More informationCS 161 Lecture 11 BFS, Dijkstra s algorithm Jessica Su (some parts copied from CLRS) 1 Review
1 Review 1 Something I did not emphasize enough last time is that during the execution of depth-firstsearch, we construct depth-first-search trees. One graph may have multiple depth-firstsearch trees,
More information24 Single-Source Shortest Paths
4 Single-Source Shortest Paths Professor Patrick wishes to find the shortest possible route from Phoenix to Indianapolis. Given a road map of the United States on which the distance between each pair of
More informationFundamental Algorithms CSCI-GA /Summer Solution to Homework 8
Fundamental Algorithms CSCI-GA.70-00/Summer 206 Solution to Homework 8 Problem (CLRS 23.-6). ( point) Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique
More informationCS 270 Algorithms. Oliver Kullmann. Analysing BFS. Depth-first search. Analysing DFS. Dags and topological sorting.
General remarks Week 5 2 We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week 5 Chapter
More informationCS420/520 Algorithm Analysis Spring 2009 Lecture 14
CS420/520 Algorithm Analysis Spring 2009 Lecture 14 "A Computational Analysis of Alternative Algorithms for Labeling Techniques for Finding Shortest Path Trees", Dial, Glover, Karney, and Klingman, Networks
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Topological sort Shortest paths Adam Smith The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle
More informationCS 270 Algorithms. Oliver Kullmann. Breadth-first search. Analysing BFS. Depth-first. search. Analysing DFS. Dags and topological sorting.
Week 5 General remarks and 2 We consider the simplest graph- algorithm, breadth-first (). We apply to compute shortest paths. Then we consider the second main graph- algorithm, depth-first (). And we consider
More informationClassical Shortest-Path Algorithms
DISTANCE PROBLEMS IN NETWORKS - THEORY AND PRACTICE Classical Shortest-Path Algorithms Nesrine Damak October 10, 2010 Abstract In this work, we present four algorithms for the shortest path problem. The
More informationQuiz 2 Practice Problems
Introduction to Algorithms: 6.006 Massachusetts Institute of Technology April 2, 2008 Professors Srini Devadas and Erik Demaine Handout 9 1 True/False Quiz 2 Practice Problems Decide whether these statements
More information(Refer Slide Time: 00:18)
Programming, Data Structures and Algorithms Prof. N. S. Narayanaswamy Department of Computer Science and Engineering Indian Institute of Technology, Madras Module 11 Lecture 58 Problem: single source shortest
More informationAlgorithms for Data Science
Algorithms for Data Science CSOR W4246 Eleni Drinea Computer Science Department Columbia University Shortest paths in weighted graphs (Bellman-Ford, Floyd-Warshall) Outline 1 Shortest paths in graphs with
More informationWeek 5. 1 Analysing BFS. 2 Depth-first search. 3 Analysing DFS. 4 Dags and topological sorting. 5 Detecting cycles. CS 270 Algorithms.
1 2 Week 5 3 4 5 General remarks We finish, by analysing it. Then we consider the second main graph- algorithm, depth-first (). And we consider one application of, of graphs. Reading from CLRS for week
More informationMore Graph Algorithms: Topological Sort and Shortest Distance
More Graph Algorithms: Topological Sort and Shortest Distance Topological Sort The goal of a topological sort is given a list of items with dependencies, (ie. item 5 must be completed before item 3, etc.)
More informationChapter 25: All-Pairs Shortest-Paths
Chapter : All-Pairs Shortest-Paths When no negative edges Some Algorithms Using Dijkstra s algorithm: O(V ) Using Binary heap implementation: O(VE lg V) Using Fibonacci heap: O(VE + V log V) When no negative
More informationTIE Graph algorithms
TIE-20106 1 1 Graph algorithms This chapter discusses the data structure that is a collection of points (called nodes or vertices) and connections between them (called edges or arcs) a graph. The common
More informationThe Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation
The Shortest Path Problem jla,jc@imm.dtu.dk Department of Management Engineering Technical University of Denmark The Shortest Path Problem Given a directed network G = (V,E,w) for which the underlying
More informationOutline. Computer Science 331. Analysis of Prim's Algorithm
Outline Computer Science 331 Analysis of Prim's Algorithm Mike Jacobson Department of Computer Science University of Calgary Lecture #34 1 Introduction 2, Concluded 3 4 Additional Comments and References
More informationCS473-Algorithms I. Lecture 14-A. Graph Searching: Breadth-First Search. Cevdet Aykanat - Bilkent University Computer Engineering Department
CS473-Algorithms I Lecture 14-A Graph Searching: Breadth-First Search 1 Graph Searching: Breadth-First Search Graph G =(V, E), directed or undirected with adjacency list repres. GOAL: Systematically explores
More informationLecture #7. 1 Introduction. 2 Dijkstra s Correctness. COMPSCI 330: Design and Analysis of Algorithms 9/16/2014
COMPSCI 330: Design and Analysis of Algorithms 9/16/2014 Lecturer: Debmalya Panigrahi Lecture #7 Scribe: Nat Kell 1 Introduction In this lecture, we will further examine shortest path algorithms. We will
More informationSources for this lecture 2. Shortest paths and minimum spanning trees
S-72.2420 / T-79.5203 Shortest paths and minimum spanning trees 1 S-72.2420 / T-79.5203 Shortest paths and minimum spanning trees 3 Sources for this lecture 2. Shortest paths and minimum spanning trees
More informationSample Solutions to Homework #4
National Taiwan University Handout #25 Department of Electrical Engineering January 02, 207 Algorithms, Fall 206 TA: Zhi-Wen Lin and Yen-Chun Liu Sample Solutions to Homework #4. (0) (a) Both of the answers
More informationTitle. Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis. Nesrine Damak. Fakultät für Informatik TU München. 20.
Title Ferienakademie im Sarntal Course 2 Distance Problems: Theory and Praxis Nesrine Damak Fakultät für Informatik TU München 20. September 2010 Nesrine Damak: Classical Shortest-Path Algorithms 1/ 35
More informationCS 561, Lecture 10. Jared Saia University of New Mexico
CS 561, Lecture 10 Jared Saia University of New Mexico Today s Outline The path that can be trodden is not the enduring and unchanging Path. The name that can be named is not the enduring and unchanging
More informationArtificial Intelligence
Artificial Intelligence Shortest Path Problem G. Guérard Department of Nouvelles Energies Ecole Supérieur d Ingénieurs Léonard de Vinci Lecture 3 GG A.I. 1/42 Outline 1 The Shortest Path Problem Introduction
More informationDijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker
Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Problem:!!
More informationSolution. violating the triangle inequality. - Initialize U = {s} - Add vertex v to U whenever DIST[v] decreases.
Solution Maintain a set U of all those vertices that might have an outgoing edge violating the triangle inequality. - Initialize U = {s} - Add vertex v to U whenever DIST[v] decreases. 1. Check if the
More informationRouting Protocols and the IP Layer
Routing Protocols and the IP Layer CS244A Review Session 2/0/08 Ben Nham Derived from slides by: Paul Tarjan Martin Casado Ari Greenberg Functions of a router Forwarding Determine the correct egress port
More informationAnalysis of Algorithms, I
Analysis of Algorithms, I CSOR W4231.002 Eleni Drinea Computer Science Department Columbia University Thursday, March 8, 2016 Outline 1 Recap Single-source shortest paths in graphs with real edge weights:
More informationDr. Alexander Souza. Winter term 11/12
Algorithms Theory 11 Shortest t Paths Dr. Alexander Souza 1. Shortest-paths problem Directed graph G = (V, E) Cost function c : E R 1 2 1 3 3 2 4 4 2 6 6 5 3 2 Distance between two vertices Cost of a path
More informationThe Shortest Path Problem
The Shortest Path Problem 1 Shortest-Path Algorithms Find the shortest path from point A to point B Shortest in time, distance, cost, Numerous applications Map navigation Flight itineraries Circuit wiring
More informationIntroduction Single-source shortest paths All-pairs shortest paths. Shortest paths in graphs
Shortest paths in graphs Remarks from previous lectures: Path length in unweighted graph equals to edge count on the path Oriented distance (δ(u, v)) between vertices u, v equals to the length of the shortest
More informationMa/CS 6a Class 27: Shortest Paths
// Ma/CS a Class 7: Shortest Paths By Adam Sheffer Naïve Path Planning Problem. We are given a map with cities and noncrossing roads between pairs of cities. Describe an algorithm for finding a path between
More informationAlgorithms and Data Structures: Minimum Spanning Trees I and II - Prim s Algorithm. ADS: lects 14 & 15 slide 1
Algorithms and Data Structures: Minimum Spanning Trees I and II - Prim s Algorithm ADS: lects 14 & 15 slide 1 Weighted Graphs Definition 1 A weighted (directed or undirected graph) is a pair (G, W ) consisting
More informationCS 561, Lecture 10. Jared Saia University of New Mexico
CS 561, Lecture 10 Jared Saia University of New Mexico Today s Outline The path that can be trodden is not the enduring and unchanging Path. The name that can be named is not the enduring and unchanging
More information1 The Shortest Path Problem
CS161 Lecture 11 Single Source Shortest Paths Scribed by: Romil Verma (2015), Virginia Date: May 8, 2016 1 The Shortest Path Problem In this lecture, we ll discuss the shortest path problem. Assume we
More information1 i n (p i + r n i ) (Note that by allowing i to be n, we handle the case where the rod is not cut at all.)
Dynamic programming is a problem solving method that is applicable to many different types of problems. I think it is best learned by example, so we will mostly do examples today. 1 Rod cutting Suppose
More informationGraph Representation
Graph Representation Adjacency list representation of G = (V, E) An array of V lists, one for each vertex in V Each list Adj[u] contains all the vertices v such that there is an edge between u and v Adj[u]
More informationLecture #10: RELAX(u, v, w) if d[v] >d[u]+w(u, v) then d[v] d[u]+w(u, v) π[v] u
Lecture #:.. raph lgorithms: hortest Path (hapter ) Problem iven a directed graph =[V,], and weight function w : R mapping edges to real valued weights. The weight of a path p = hv o,v,..., v k i is the
More informationECE250: Algorithms and Data Structures Single Source Shortest Paths Bellman-Ford Algorithm
ECE250: Algorithms and Data Structures Single Source Shortest Paths Bellman-Ford Algorithm Ladan Tahvildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Group Dept. of
More informationTaking Stock. Last Time Flows. This Time Review! 1 Characterize the structure of an optimal solution
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 26 Jeff Linderoth Last Time Department of Industrial and Systems Engineering Lehigh University April 2, 2007 This Time Review! Jeff Linderoth
More informationSingle Source Shortest Path: The Bellman-Ford Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley
Single Source Shortest Path: The Bellman-Ford Algorithm Slides based on Kevin Wayne / Pearson-Addison Wesley Single Source Shortest Path Problem Shortest path network. Directed graph G = (V, E, w). Weight
More informationChapter 22. Elementary Graph Algorithms
Graph Algorithms - Spring 2011 Set 7. Lecturer: Huilan Chang Reference: (1) Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. (2) Lecture notes from C. Y. Chen
More informationDijkstra s Algorithm. Dijkstra s algorithm is a natural, greedy approach towards
CPSC-320: Intermediate Algorithm Design and Analysis 128 CPSC-320: Intermediate Algorithm Design and Analysis 129 Dijkstra s Algorithm Dijkstra s algorithm is a natural, greedy approach towards solving
More informationCS4800: Algorithms & Data Jonathan Ullman
CS4800: Algorithms & Data Jonathan Ullman Lecture 13: Shortest Paths: Dijkstra s Algorithm, Heaps DFS(?) Feb 0, 018 Navigation s 9 15 14 5 6 3 18 30 11 5 0 16 4 6 6 3 19 t Weighted Graphs A graph with
More informationTopological Sort. Here a topological sort would label A with 1, B and C with 2 and 3, and D with 4.
Topological Sort The goal of a topological sort is given a list of items with dependencies, (ie. item 5 must be completed before item 3, etc.) to produce an ordering of the items that satisfies the given
More informationTutorial. Question There are no forward edges. 4. For each back edge u, v, we have 0 d[v] d[u].
Tutorial Question 1 A depth-first forest classifies the edges of a graph into tree, back, forward, and cross edges. A breadth-first tree can also be used to classify the edges reachable from the source
More informationProblem Set 8 Solutions
Introduction to Algorithms November 22, 25 Massachusetts Institute of Technology 6.46J/8.4J Professors Erik D. Demaine and Charles E. Leiserson Handout 27 Problem Set 8 Solutions Problem 8-. No left turns
More informationRepresentations of Weighted Graphs (as Matrices) Algorithms and Data Structures: Minimum Spanning Trees. Weighted Graphs
Representations of Weighted Graphs (as Matrices) A B Algorithms and Data Structures: Minimum Spanning Trees 9.0 F 1.0 6.0 5.0 6.0 G 5.0 I H 3.0 1.0 C 5.0 E 1.0 D 28th Oct, 1st & 4th Nov, 2011 ADS: lects
More informationDijkstra s Algorithm. Single source shortest paths for a directed acyclic graph
Dijkstra s Algorithm Single source shortest paths for a directed acyclic graph Single-Source Shortest Paths We want to find the shortest paths between Binghamton and New York City, Boston, and Washington
More informationCSE 331: Introduction to Algorithm Analysis and Design Graphs
CSE 331: Introduction to Algorithm Analysis and Design Graphs 1 Graph Definitions Graph: A graph consists of a set of verticies V and a set of edges E such that: G = (V, E) V = {v 0, v 1,..., v n 1 } E
More information