Chapter 25: All-Pairs Shortest-Paths
|
|
- Tobias French
- 6 years ago
- Views:
Transcription
1 Chapter : All-Pairs Shortest-Paths
2 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 cycles Floyd-Warshall [96]: O(V ) time When negative cycles Using Bellman-Ford algorithm: O(V E) = O(V ) Johnson [977]: O(VE + V log V) time based on a clever combination of Bellman-Ford and Dijkstra
3 A dynamic programming approach. characterize the structure of an optimal solution,. recursively define the value of an optimal solution,. compute the value of an optimal solution in a bottom-up fashion.
4 The structure of an optimal solution Consider a shortest path p from vertex i to vertex j, and suppose that p contains at most m edges. Assume that there are no negative-weight cycles. Hence m n- is finite.
5 The structure of an optimal solution (cont.) If i = j, then p has weight and no edge If i j, we decompose p into i ~ k -> j where p contains at most m- edges. Moreover, p is a shortest path from i to k and δ(i,j) = δ(i,k) + w kj, where δ(i,j) dente the shortest weight path from i to j p'
6 Recursive solution to the allpairs shortest-path problem Define: l (m) ij = minimum weight of any path from i to j that contains at most m edges. if i = j l () = ij if i j Then l (m) ij = min{ l (m-) ij, min k n {l (m-) ik + w kj }} = min k n {l (m-) ik + w kj } (why?) 6
7 Recursive solution to the allpairs shortest-path problem Since shortest path from i to j contains at most n- edges, δ(i,j) = l ij (n-) = l ij (n) = l ij (n+) = Computing the shortest-path weight bottom up: Compute L (),L (),., L (n-) where L (m) =(l ij (m) ) for all i and j ote that L () = W. 7
8 () L () L Example: W = L () = L () x W
9 () L () L L () = L () x W L () = L () x W
10 EXTEDED-SHORTEST- PATHS(L, W) Given matrices L (m-) and W return L (m) n <- L.row Let L = (l ij ) be a new n x n matrix for i = to n for j = to n l ij = 6 for k = to n 7 l ij = min(l ij, l ik + w kj ) 8 return L
11 Matrix Multiplication Let l (m-) -> a w -> b l (m) -> c min -> + + -> C ij = k= to n a ik b kj l ij (m) = min k n {l ik (m-) + w kj } time complexity : O(n )
12 SLOW-ALL-PAIRS- SHORTEST-PATHS(W) L () = L () W = W L () = L () W = W L () = L () W = W L (n-) = L (n-) W = W n-
13 SLOW-ALL-PAIRS- SHORTEST-PATHS(W) n = W.rows L () = W for m = to n- let L (m) be a new n x n matrix L (m) = EXTEDED-SHORTEST- PATHS( L (m-), W ) 6 return L (n-) Time complexity : O(n )
14 Improving the running time L () = W L () = W =W.W L () =W = W.W. L (n) = W n =W n/.w n/ i.e., using repeating squaring! Time complexity: O(n lg n)
15 FASTER-ALL-PAIRS-SHORTEST- PATHS FASTER-ALL-PAIRS-SHORTEST-PATHS(W). n =W.row. L () =W. m =. while m < n-. let L (m) be a new n x n matrix 6. L (m) = Extend-Shorest-Path(L (m), L (m) ) 7. m = m 8. return L (m)
16 The Floyd-Warshall algorithm A different dynamic programming formulation The structure of a shortest path: Let V(G)={,,,n}. For any pair of vertices i, j єv, consider all paths from i to j whose intermediate vertices are drawn from {,,,k}, and let p be a minimum weight path among them. 6
17 The structure of a shortest path If k is not in p, then all intermediate vertices are in {,,,k-}. If k is an intermediate vertex of p, then p p can be decomposed into i ~ k p ~ j where p is a shortest path from i to k with all the intermediate vertices in {,,,k-} and p is a shortest path from k to j with all the intermediate vertices in {,,,k-}. 7
18 A recursive solution to the allpairs shortest path Let d ij (k) =the weight of a shortest path from vertex i to vertex j with all intermediate vertices in the set {,,,k}. d ij (k) = w ij if k = = min(d ij (k-), d ik (k-) + d kj (k-) ) if k D (n) = (d ij (n) ) if the final solution! 8
19 FLOYD-WARSHALL(W). n = W.rows. D () = W. for k = to n. Let D (k) = (d ij (k) ) be a new n x n matrix. for i = to n 6. for j = to n 7. d ij (k) = min (d ij (k-), d ik (k-) + d kj (k-) ) 8. return D (n) Complexity: O(n ) 9
20 Example () D () D () ()
21 6 7 8 () D () () D ()
22 6 8 7 () D () D () ()
23 Constructing a shortest path π (), π (),, π (n) π (k) ij : is the predecessor of the vertex j on a shortest path from vertex i with all intermediate vertices in the set {,,,k}. π () ij = IL if i=j or w ij = = i if i j and w ij < π ij (k) = π ij (k-) if d ij (k-) d ik (k-) + d kj (k-) = π kj (k-) if d ij (k-) > d ik (k-) + d kj (k-)
24 Transitive closure of a directed graph Given a directed graph G = (V, E) with V = {,,, n} The transitive closure of G is G*= (V, E*) where E*={(i, j) there is a path from i to j in G}. Modify FLOYD-WARSHALL algorithm: t ij () = if i j and (i,j) E for k if i=j or (i,j) є E t ij (k) = t ij (k-) (t ik (k-) t kj (k-) )
25 Transitive-Closure of a Directed Graph Given a directed graph G=(V, E) with V= {,, n} We might wish to determine whether G contains a path from I to j for all vertex pairs i, j єv. We define the transitive closure of G as the graph G* = (V, E*), where E* = {(i, j): there is a path from vertex i to vertex j in G}
26 TRASITIVE-CLOSURE(G) n = G.V Let T () = (t () ij ) be a new n x n matrix for i = to n for j = to n if i == j or (i, j) G.E 6 t () ij = 7 else t () ij = Time complexity: O(n ) 8 for k = to n 9 Let T (k) = (t (k) ij ) be a new n x n matrix for i = to n for j = to n t (k) ij = t (k-) ij (t (k-) ik t (k-) kj ) return T (n) 6
27 7 Example () T () T () T () T () T
28 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 cycles Floyd-Warshall [96]: O(V ) time When negative cycles Using Bellman-Ford algorithm: O(V E) = O(V ) Johnson [977]: O(VE + V log V) time based on a clever combination of Bellman-Ford and Dijkstra 8
29 Johnson s algorithm for sparse graphs If all edge weights in G are nonnegative, we can find all shortest paths in O(V lg V + VE) by using Dijkstra s algorithm with Fibonacci heap Bellman-Ford algorithm takes O(V E) Using reweighting technique 9
30 Reweighting technique If G has negative-weighted edge, we compute a new set of nonnegative weight that allows us to use the same method. The new set of edge weight ŵ satisfies:. For all pairs of vertices u, v єv, a shortest path from u to v using weight function w is also a shortest path from u to v using the weight function ŵ. (u,v) є E(G), ŵ(u,v) is nonnegative
31 Lemma: (Reweighting doesn t change shortest paths) Given a weighted directed graph G = (V, E) with weight function w:e R, let h:v R be any function mapping vertices to real numbers. For each edge (u,v) є E, ŵ(u,v) = w(u,v) + h(u) h(v) Let P=<v,v,,v k > be a path from vertex v to v k Then w(p) = δ(v,v k ) if and only if ŵ(p) = ˆ (v,v k ) Also, G has a negative-weight cycle using weight function w iff G has a negative weight cycle using weight function ŵ. Question: how to setting the value of h(v i ) for all i?
32 Example:
33 h(v) = δ(s, v) ŵ(u, v) = w(u, v) + h(u) h(v)
34 Proof ŵ(p) = w(p) + h(v ) h(v k ) ŵ(p) = ŵ(v i-,v i ) k k i = (w(v i-,v i ) + h(v i- )-h(v i )) i k = w(v i-,v i ) + h(v )-h(v k ) i = w(p) + h(v ) h(v k )
35 Proof Because h(v ) and h(v k ) do not depend on the path, if one path from v to v k is shorter than another using weight function w, then it is also shorter using ŵ. Thus, w(p) = δ(v,v k ) if and only if ŵ(p) = (v,v k )
36 Proof G has a negative-weight cycle using w iff G has a negative-weight cycle using ŵ. Consider any cycle C=<v,v,,v k > with v =v k. Then ŵ(c) = w(c) + h(v ) h(v k ) = w(c). Question: how to setting the value of h(v i ) for all i? 6
37 Producing nonnegative weight by reweighting Given a weighted directed graph G = (V, E) We make a new graph G = (V,E ), V = V {s}, E = E {(s,v): v є V} and w(s,v) =, for all v in V Let h(v) = δ(s, v) for all v V We have h(v) h(u) + w(u, v) (if there is no negative weight cycle) (why?) ŵ(u, v) = w(u, v) + h(u) h(v) 7
38 Example:
39 S
40 S
41 h(v) = δ(s, v) ŵ(u, v) = w(u, v) + h(u) h(v) S - - -
42 JOHSO algorithm Computing G, where G.V = G.V {s} and G.E= G.E {(s, v): v є G.V} and w(s, v) =. if BELLMA-FORD(G, w, s)= FALSE print the input graph contains negative weight cycle else for each vertex v є G.V set h(v) to be the value of δ(s, v) computed by the BF algorithm 6 for each edge (u, v) є G.E, ŵ(u, v) = w(u, v) + h(u) h(v)
43 JOHSO algorithm 7 Let D = (d uv ) be a new n x n matrix 8 for each vertex u є G.V run DIJKSTRA (G, ŵ, u) to compute ˆ (u, v) for all v є V[G]. for each vertex v є G.V d uv = (u, v) + h(v) h(u) ˆ return D Complexity: O(V lgv + VE)
44 / /- / /- / / / /- / /- / / /7 / /
45 / /- /- /8 / / /- / / /6
46 Homework Practice at home:.-,.-,.-6 Exercises:.-,.-6,.-8 (Due: Jan. ) Practice at home :.-, Exercises:.- (Due: Jan. ) Bonus: Write a program to find all pairs shortest path of a graph G. There may exist negative weight cycle on graph G. 6
Algorithms. All-Pairs Shortest Paths. Dong Kyue Kim Hanyang University
Algorithms All-Pairs Shortest Paths Dong Kyue Kim Hanyang University dqkim@hanyang.ac.kr Contents Using single source shortest path algorithms Presents O(V 4 )-time algorithm, O(V 3 log V)-time algorithm,
More informationMA 252: Data Structures and Algorithms Lecture 36. Partha Sarathi Mandal. Dept. of Mathematics, IIT Guwahati
MA 252: Data Structures and Algorithms Lecture 36 http://www.iitg.ernet.in/psm/indexing_ma252/y12/index.html Partha Sarathi Mandal Dept. of Mathematics, IIT Guwahati The All-Pairs Shortest Paths Problem
More informationAll Pairs Shortest Paths
All Pairs Shortest Paths Given a directed, connected weighted graph G(V, E), for each edge u, v E, a weight w(u, v) is associated with the edge. The all pairs of shortest paths problem (APSP) is to find
More informationAdvanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis
Advanced Algorithm Design and Analysis (Lecture 5) SW5 fall 2007 Simonas Šaltenis 3.2.12 simas@cs.aau.dk All-pairs shortest paths Main goals of the lecture: to go through one more example of dynamic programming
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 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 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 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 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 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 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 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 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 Path
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
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 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 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 informationAll Shortest Paths. Questions from exercises and exams
All Shortest Paths Questions from exercises and exams The Problem: G = (V, E, w) is a weighted directed graph. We want to find the shortest path between any pair of vertices in G. Example: find the distance
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 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 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 informationWeighted Graph Algorithms Presented by Jason Yuan
Weighted Graph Algorithms Presented by Jason Yuan Slides: Zachary Friggstad Programming Club Meeting Weighted Graphs struct Edge { int u, v ; int w e i g h t ; // can be a double } ; Edge ( int uu = 0,
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 informationShortest Path Algorithm
Shortest Path Algorithm Shivani Sanan* 1, Leena jain 2, Bharti Kappor 3 *1 Assistant Professor, Faculty of Mathematics, Department of Applied Sciences 2 Associate Professor & Head- MCA 3 Assistant Professor,
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 informationDirected Graphs. DSA - lecture 5 - T.U.Cluj-Napoca - M. Joldos 1
Directed Graphs Definitions. Representations. ADT s. Single Source Shortest Path Problem (Dijkstra, Bellman-Ford, Floyd-Warshall). Traversals for DGs. Parenthesis Lemma. DAGs. Strong Components. Topological
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 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 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 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 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 informationComputer 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 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 informationLecture 18 Solving Shortest Path Problem: Dijkstra s Algorithm. October 23, 2009
Solving Shortest Path Problem: Dijkstra s Algorithm October 23, 2009 Outline Lecture 18 Focus on Dijkstra s Algorithm Importance: Where it has been used? Algorithm s general description Algorithm steps
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 informationGraphs II - Shortest paths
Graphs II - Shortest paths Single Source Shortest Paths All Sources Shortest Paths some drawings and notes from prof. Tom Cormen Single Source SP Context: directed graph G=(V,E,w), weighted edges The shortest
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 informationDijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the
Dijkstra s Algorithm Last time we saw two methods to solve the all-pairs shortest path problem: Min-plus matrix powering in O(n 3 log n) time and the Floyd-Warshall algorithm in O(n 3 ) time. Neither of
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 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 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 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 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 Non greedy algorithms (which we should have covered
1 Non greedy algorithms (which we should have covered earlier) 1.1 Floyd Warshall algorithm This algorithm solves the all-pairs shortest paths problem, which is a problem where we want to find the shortest
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 informationMon Tue Wed Thurs Fri
In lieu of recitations 320 Office Hours Mon Tue Wed Thurs Fri 8 Cole 9 Dr. Georg Dr. Georg 10 Dr. Georg/ Jim 11 Ali Jim 12 Cole Ali 1 Cole/ Shannon Ali 2 Shannon 3 Dr. Georg Dr. Georg Jim 4 Upcoming Check
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 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 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 informationDynamic Programming: 1D Optimization. Dynamic Programming: 2D Optimization. Fibonacci Sequence. Crazy 8 s. Edit Distance
Dynamic Programming: 1D Optimization Fibonacci Sequence To efficiently calculate F [x], the xth element of the Fibonacci sequence, we can construct the array F from left to right (or bottom up ). We start
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 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 informationParallel Graph Algorithms
Parallel Graph Algorithms Design and Analysis of Parallel Algorithms 5DV050/VT3 Part I Introduction Overview Graphs definitions & representations Minimal Spanning Tree (MST) Prim s algorithm Single Source
More informationMinimum Spanning Trees My T. UF
Introduction to Algorithms Minimum Spanning Trees @ UF Problem Find a low cost network connecting a set of locations Any pair of locations are connected There is no cycle Some applications: Communication
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 informationCS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016
CS 125 Section #5 Graph Traversal and Linear Programs October 6, 2016 1 Depth first search 1.1 The Algorithm Besides breadth first search, which we saw in class in relation to Dijkstra s algorithm, there
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 informationCSE 502 Class 23. Jeremy Buhler Steve Cole. April BFS solves unweighted shortest path problem. Every edge traversed adds one to path length
CSE 502 Class 23 Jeremy Buhler Steve Cole April 14 2015 1 Weighted Version of Shortest Paths BFS solves unweighted shortest path problem Every edge traversed adds one to path length What if edges have
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 informationDynamic Programming Shabsi Walfish NYU - Fundamental Algorithms Summer 2006
Dynamic Programming What is Dynamic Programming? Technique for avoiding redundant work in recursive algorithms Works best with optimization problems that have a nice underlying structure Can often be used
More informationCS161 - Minimum Spanning Trees and Single Source Shortest Paths
CS161 - Minimum Spanning Trees and Single Source Shortest Paths David Kauchak Single Source Shortest Paths Given a graph G and two vertices s, t what is the shortest path from s to t? For an unweighted
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 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 informationShortest Paths. March 21, CTU in Prague. Z. Hanzálek (CTU) Shortest Paths March 21, / 44
Shortest Paths Zdeněk Hanzálek hanzalek@fel.cvut.cz CTU in Prague March 21, 2017 Z. Hanzálek (CTU) Shortest Paths March 21, 2017 1 / 44 Table of contents 1 Introduction Problem Statement Negative Weights
More informationFinal Exam Solutions
Introduction to Algorithms December 14, 2010 Massachusetts Institute of Technology 6.006 Fall 2010 Professors Konstantinos Daskalakis and Patrick Jaillet Final Exam Solutions Final Exam Solutions Problem
More informationLecture 14: Shortest Paths Steven Skiena
Lecture 14: Shortest Paths Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.stonybrook.edu/ skiena Problem of the Day Suppose we are given
More informationCSE 101, Winter Design and Analysis of Algorithms. Lecture 11: Dynamic Programming, Part 2
CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 11: Dynamic Programming, Part 2 Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Goal: continue with DP (Knapsack, All-Pairs SPs, )
More informationGraph Algorithms (part 3 of CSC 282),
Graph Algorithms (part of CSC 8), http://www.cs.rochester.edu/~stefanko/teaching/10cs8 1 Schedule Homework is due Thursday, Oct 1. The QUIZ will be on Tuesday, Oct. 6. List of algorithms covered in the
More informationAlgorithms and Data Structures
Algorithms and Data Structures Graphs : Shortest Paths Marius Kloft Content of this Lecture Single-Source-Shortest-Paths: Dijkstra s Algorithm Single-Source-Single-Target All-Pairs Shortest Paths Transitive
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 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 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 informationLecture 5: Graph algorithms 1
DD2458, Problem Solving and Programming Under Pressure Lecture 5: Graph algorithms 1 Date: 2008-10-01 Scribe(s): Mikael Auno and Magnus Andermo Lecturer: Douglas Wikström This lecture presents some common
More informationParallel Graph Algorithms
Parallel Graph Algorithms Design and Analysis of Parallel Algorithms 5DV050 Spring 202 Part I Introduction Overview Graphsdenitions, properties, representation Minimal spanning tree Prim's algorithm Shortest
More informationIntroduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15
600.363 Introduction to Algorithms / 600.463 Algorithms I Lecturer: Michael Dinitz Topic: Shortest Paths Date: 10/13/15 14.1 Introduction Today we re going to talk about algorithms for computing shortest
More information1 More on the Bellman-Ford Algorithm
CS161 Lecture 12 Shortest Path and Dynamic Programming Algorithms Scribe by: Eric Huang (2015), Anthony Kim (2016), M. Wootters (2017) Date: May 15, 2017 1 More on the Bellman-Ford Algorithm We didn t
More informationLast week: Breadth-First Search
1 Last week: Breadth-First Search Set L i = [] for i=1,,n L 0 = {w}, where w is the start node For i = 0,, n-1: For u in L i : For each v which is a neighbor of u: If v isn t yet visited: - mark v as visited,
More informationCS 125 Section #10 Midterm 2 Review 11/5/14
CS 125 Section #10 Midterm 2 Review 11/5/14 1 Topics Covered This midterm covers up through NP-completeness; countability, decidability, and recognizability will not appear on this midterm. Disclaimer:
More informationUnit-5 Dynamic Programming 2016
5 Dynamic programming Overview, Applications - shortest path in graph, matrix multiplication, travelling salesman problem, Fibonacci Series. 20% 12 Origin: Richard Bellman, 1957 Programming referred to
More informationKonigsberg Bridge Problem
Graphs Konigsberg Bridge Problem c C d g A Kneiphof e D a B b f c A C d e g D a b f B Euler s Graph Degree of a vertex: the number of edges incident to it Euler showed that there is a walk starting at
More informationUNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:
UNIT 5 CSE 103 - Unit V- Graph GRAPH Graph is another important non-linear data structure. In tree Structure, there is a hierarchical relationship between, parent and children that is one-to-many relationship.
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 informationCSC 373 Lecture # 3 Instructor: Milad Eftekhar
Huffman encoding: Assume a context is available (a document, a signal, etc.). These contexts are formed by some symbols (words in a document, discrete samples from a signal, etc). Each symbols s i is occurred
More informationDynamic-Programming algorithms for shortest path problems: Bellman-Ford (for singlesource) and Floyd-Warshall (for all-pairs).
Lecture 13 Graph Algorithms I 13.1 Overview This is the first of several lectures on graph algorithms. We will see how simple algorithms like depth-first-search can be used in clever ways (for a problem
More informationThe Shortest-Path Problem : G. Dantzig. 4-Shortest Paths Problems. The Shortest-Path Problem : G. Dantzig (continued)
The Shortest-Path Problem : G. Dantzig 4-Shortest Paths Problems Bruno MARTIN, University of Nice - Sophia Antipolis mailto:bruno.martin@unice.fr http://deptinfo.unice.fr/~bmartin/mathmods Problem: Find
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 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 informationDatenstrukturen und Algorithmen
1 Datenstrukturen und Algorithmen Exercise 9 FS 2018 Program of today 2 1 Feedback of last exercise 2 Repetition theory 3 Programming Task 1. Feedback of last exercise 3 Topological Sorting 4 A B Graph
More informationCS 125 Section #6 Graph Traversal and Linear Programs 10/13/14
CS 125 Section #6 Graph Traversal and Linear Programs 10/13/14 1 Depth first search 1.1 The Algorithm Besides breadth first search, which we saw in class in relation to Dijkstra s algorithm, there is one
More informationLecture 6: Shortest distance, Eulerian cycles, Maxflow
DD2458, Problem Solving and Programming Under Pressure Lecture 6: Shortest distance, Eulerian cycles, Maxflow Date: 2008-10-06 Scribe(s): Adam Kull, David Vuorio Lecturer: Douglas Wikström 1 Shortest path
More informationModule 5 Graph Algorithms
Module 5 Graph lgorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu 5. Graph Traversal lgorithms Depth First
More informationReview of course COMP-251B winter 2010
Review of course COMP-251B winter 2010 Lecture 1. Book Section 15.2 : Chained matrix product Matrix product is associative Computing all possible ways of parenthesizing Recursive solution Worst-case running-time
More information1 Dynamic Programming
CS161 Lecture 13 Dynamic Programming and Greedy Algorithms Scribe by: Eric Huang Date: May 13, 2015 1 Dynamic Programming The idea of dynamic programming is to have a table of solutions of subproblems
More informationLecture 4: Graph Algorithms
Lecture 4: Graph Algorithms Definitions Undirected graph: G =(V, E) V finite set of vertices, E finite set of edges any edge e = (u,v) is an unordered pair Directed graph: edges are ordered pairs If e
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 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 information1 Single Source Shortest Path Algorithms
15-850: Advanced Algorithms CMU, Spring 2017 Lecture #4: Shortest Paths and Seidel s Algorithm 2/1/17 Lecturer: Anupam Gupta Scribe: Nicholas Sieger, Adam Kavka In this lecture, we did a review of single
More informationData Structures and Algorithms. Werner Nutt
Data Structures and Algorithms Werner Nutt nutt@inf.unibz.it http://www.inf.unibz/it/~nutt Chapter 10 Academic Year 2012-2013 1 Acknowledgements & Copyright Notice These slides are built on top of slides
More information