Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths. Reading: AM&O Chapter 5

Size: px
Start display at page:

Download "Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths. Reading: AM&O Chapter 5"

Transcription

1 Lecture 7: Shortest Paths in Graphs with Negative Arc Lengths Reading: AM&O Chapter

2 Label Correcting Methods Assume the network G is allowed to have negative arc lengths but no directed negativelyweighted cycles. Assume that there exist a directed (s, j)-path for every node j, and that all arc lengths are integer. Let C be the largest absolute value of an arc length. Recall Bellman s conditions for a set of node labels d j to comprise correct shortest (s, j)-path distances: (a) for each node j, there exists at least one (s, j)-path of length d j (b) Bellman s Equations are satisfied: d s = 0 d j = min{d i + c ij : i B(j)} j s. Idea of label correcting: Look for arcs (i, j) for which d j > d i + c ij and correct d j to satisfy d j = d i + c ij

3 Generic Label Correcting Procedure set labels d j = { 0 j = s otherwise while d j > d i + c ij for some arc (i, j) { set d j = d i + c ij, Pred(j)=(i, j) } Correctness and Complexity: 1. The Pred() graph will eventually include every node, and can never produce a cycle (Why?). Thus every node i will eventually have a path from s of length exactly d i. Labels are nonincreasing, and each of the n labels can become no smaller than nc. Thus the algorithm must terminate in at most n C iterations, with labels satistying Bellman s conditions. Problem: Not polynomial

4 Modified Label Correcting Algorithm Again we can modify FINDPATH to improve the complexity of the generic procedure. { 0 v = s set labels d v = otherwise set LIST = {s}, while LIST begin select k LIST for i A(k) do if d i > d k + c ki then begin set d i = d k + c ki set Pred(i)=(k, i) if i LIST than add i to LIST end remove k from LIST end

5 Example Problem 0 s 1 node 1 LIST Example Problem

6 0 s 1 node 1 LIST ,

7 Example Problem 0 s 1 10 node 1 LIST , 0 10,

8 Example Problem s node 1 LIST , 0 10, ,

9 Example Problem 0 s node 1 LIST , 0 10, , ,

10 Example Problem 0 s node 1 LIST , 0 10, , , ,

11 Example Problem s 1 10 node 1 LIST , 0 10, , , ,

12 Example Problem s 1 10 node 1 LIST , 0 10, , , ,

13 Theorem: If elements from LIST are chosen in FIFO order, then the modified label correcting algorithm finds all minimum length (s, i)-paths in O(nm) steps. Proof: Because of the FIFO search order, a node i is reexamined only after every other node whose label was changed before i has been examined. Since a node that has not had its label changed will not affect any other labels, we can assume WLOG that in a particular pass of the algorithm all nodes are examined.

14 Claim: After the k th stage, the algorithm has determined the correct shortest path distance for all nodes i for which the shortest (s, i)-paths has at most k arcs. Proof of claim: Clearly true for k = 0. Now assume that the claim is true after k 0 passes. Since WLOG the algorithm examines all nodes in the (k + 1) st pass, then any node for whom the shortest path is of length k + 1 must be given the correct shortest path distance in the (k+1) st pass. Therefore the algorithm will have found the correct shortest distance labels after at most n 1 passes, each pass of which requires looking at possibly all of the edges. The total complexity is thus O(nm).

15 Converting Negative Arc Weights to Nonnegative Arc Weights Properties of shortest path distances: It follows directly from Label-Correcting Algorithm that the final set of distances d i satisfy (i) d i d j + c ij for every arc (i, j), and (ii) d i = d j + c ij for every arc in the shortest path tree. Useful Fact: Let π i, i N be any set of numbers assigned to the nodes, and set c π ij = c ij π i + π j. Then every path P between two nodes s and t will have c π -length c π (P ) = c(p ) π s + π t.

16 Valuable Application Suppose you solved the Shortest s-to-all Path Problem for a graph G with general arc weights, and obtained the correct shortest (s, i)-path distances d i, i N. If we set π = d above, then it follows directly from the the above two observations that (i) c π ij = c ij + d i d j 0 for all arcs (i, j), (ii) c π ij = 0 for all arcs in the shortest path tree, (iii) for any pair of nodes s and t, the shortest c π -length (s, t)-paths and the shortest c-length (s, t)-paths will be identical. In particular, it follows from (i) and (iii) that once you find all shortest (s, i)-paths for one s using, say label correcting methods, than any other shortest (i, j)-paths can be found using Dijkstra s Algorithm (which is much faster).

17 Example Final Label Correcting Distances Adjusted Arc Weights s 1 s

18 Example: Finding shortest pairs between all pairs of nodes involves n applications of a shortest (s, j)-path algorithm (one for each s). Using the Modified Label Correcting Algorithm will take O(n m) time, but with the above procedure the time is now O(nS(m, n)) Where S(m, n) is the fastest implementation of Dijkstra s Algorithm. This could be as small as O(nm + n log n) (Fibonacci heaps) or O(nm + n log C) (radix+fibonacci heaps).

19 Matrix Methods for Finding All-Pairs Shortest Paths Given: n n matrix C of arc costs for n-node graph G where c ij = 0 if i = j and c ij = if arc (i, j) is not present for which there are no negative weight directed cycles. Find: n n matrix D all-pair shortest path lengths (that is, d ij = shortest path from i to j, and if no (i, j)-path exists). General Procedure: Produce the sequence D 0, D 1,..., D r of n n matrices, with D 0 = C and D r = D.

20 Matrix Multiplication Method D k has entries [ d k shortest length of an (i, j)-path [i, j] = containing at most k + 1 arcs The update from D k 1 to D k is the matrix multiplication D k = D k 1 C, with the arithmetic operations redefined as follows: where numbers were multiplied, they are now added; where numbers were added, the minimum is now found. and D n now represents the all-pairs shortest path lengths. ] Complexity: O(n log n) (by successive squaring )

21 Example D 0 = D 1 = D =

22 Floyd-Warshall Method D k has entries d k [i, j] = shortest length of an (i, j)-path all of whose interior nodes are in the set {1,,..., k} The update from D k 1 to D k is produced by the pivot operation d k [i, j] = min{d k 1 [i, j], d k 1 [i, k] + d k 1 [k, j]} and D n now represents the all-pairs shortest path lengths.

23 Floyd-Warshall Procedure Pred[i, j] = node preceding j on the shortest (i, j)- path Initialize: set d[i, j] = Pred[i, j] = i all i, j 0 i = j c ij (i, j) A i j, (i, j) A for k = 1,..., n do for i = 1,..., n do for j = 1,..., n do if d[i, j] > d[i, k] + d[k, j] then begin set d[i, j] = d[i, k] + d[k, j] set Pred[i, j]=pred[k, j] end Complexity: O(n )

24 Example D k ( ( ( ( ( ) ) ) ) ) k = 0 k = 1 k = k = (no change) k = Pred k ( ( ( ( ( ) ) ) ) ) Shortest (1,)-path: 1=Pred(1,) =Pred(1,) =Pred(1,)

25 Finding Negative Cycles The Floyd-Warshall Algorithm will find negative cycles naturally. The first time a negative cycle is encountered, it will do so by creating a negative number in one of the diagonal elements of the array. The corresponding change in the Pred array will allow you to reconstruct the cycle D k ( ( ) ) k = 0 k = 1 k = Pred k ( ( ) ) Cycle: =Pred(,) =Pred(,1) 1=Pred(,)

26 Application: The Tramp Steamer Problem A tramp steamer travels from port to port, doing business at each of the ports it visits. The net profit counting travel costs of making the trip from Port i to Port j is p ij, and the time (in days) to get from Port i to Port j is τ ij (all data are positive integers). The steamer captain wants to choose a circuit W : i 1, i,..., i k = i 1 which has maximum mean daily profit µ(w ) = k 1 j=1 p i j i j+1 k 1 j=1 τ. i j i j+1

27 Choose a target value µ and attempt to determine if there is a route W which exceeds the daily profit target, µ(w ) > µ, or equivalently, (u,v) W (µτ uv p uv ) < 0 Letting c uv = µτ uv p uv, we are interested in finding a negative length cycle in G. Cases: G has a negative cycle: Then µ underestimates the value of the maximum mean daily profit. Increase µ and try again. G has only positive length cycles: Then µ overestimates the value of the maximum mean daily profit. Decrease µ and try again. G has a minimum cycle W of zero length: Then µ = µ is the correct value for the cycle with maximum mean daily profit, and W is the optimal cycle.

28 Binary Search to Find the Correct µ Facts: Let P = max{p uv : (u, v) A} and τ 0 = max{τ uv : (u, v) A} 1. The minimum value for µ is P, and the maximum value for µ is P.. If W 1 and W are two cycles in G with different mean daily profits µ(w 1 ) and µ(w ), then µ(w 1 ) µ(w ) 1/(nτ 0 ) The binary search procedure searches for µ within an interval [µ, µ] = {µ : µ µ µ} known to contain µ, progressively halving the interval based on the outcome of the negative cycle procedure.

29 The Procedure 1. Begin with the interval [ P, P ]. Now for interval [µ, µ] obtained in a general step of the procedure:. Test for a negative cycle, using the value µ 0 = (µ + µ)/. If a negative cycle is found in G, then reset the interval to [µ, µ] = [µ 0, µ]. If only positive cycles are found, then reset the interval to [µ, µ] = [µ, µ 0 ]. If the minimum length cycle has zero length, then halt the algorithm, returning the value µ = µ and the corresponding cycle of maximum mean daily profit.

30 Termination of the algorithm: If the algorithm fails to find a zero length cycle by the time the interval [µ, µ] is small enough so that µ µ < 1/(nτ 0 ), then there must be exactly one number µ [µ, µ] having denominator 1/(nτ 0 ). By Fact this must be the maximum mean daily profit value, and so we run Step one time to find the optimal cycle W. Complexity of procedure: The number of steps in the binary search procedure is O(log((nτ 0 ) P )) = O(log((nτ 0 ) P )), each of which requires one search for negative cycles. Using Floyd-Warshall, the complexity becomes O(n log((nτ 0 ) P ))).

31 Example Consider the following tramp steamer problem, where the arcs are marked p ij, τ ij : 1,,,,1,1, Note that 1 1 is the maximum length cycle using either p ij or p ij τ for ij arc weights. Using binary search with P = and τ 0 =, we have the following sequence of stages:

32 1 [µ, µ] = [, ], µ 0 = [µ, µ] = [0, ], µ 0 =

33 1 1 0 [µ, µ] = [, ], µ 0 = / 1/ [µ, µ] = [, ], µ 0 =

34 1 1/ / 1/ 1/ / / [µ, µ] = [, /], µ 0 = 9/ At this point we obtain zero-length cycle 1, which is the minimum-mean-length cycle, of mean length = 9. Note that if no zero-length cycle was found, we would have continued until the interval size reached µ µ < 1/(nτ 0 ) =.01 which would have taken another stages.

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 22 All-Pairs Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 All Pairs

More information

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 017 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

Shortest paths: label setting

Shortest paths: label setting : label setting CE 377K February 19, 2015 REVIEW HW 2 posted, due in 2 weeks Review Basic search algorithm Prim s algorithm Review Algorithm (Assumes that the network is connected.) 1 Arbitrarily choose

More information

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk CMPS 6610 Fall 018 Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight function w

More information

All-Pairs Shortest Paths

All-Pairs Shortest Paths All-Pairs Shortest Paths Version of October 28, 2016 Version of October 28, 2016 All-Pairs Shortest Paths 1 / 26 Outline Another example of dynamic programming Will see two different dynamic programming

More information

CS 4407 Algorithms Lecture: Shortest Path Algorithms

CS 4407 Algorithms Lecture: Shortest Path Algorithms CS 440 Algorithms Lecture: Shortest Path Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Shortest Path Problem General Lemmas and Theorems. Algorithms Bellman-Ford

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms, Lecture 5 // Introduction to Algorithms 6.46J/.4J LECTURE Shortest Paths I Properties o shortest paths Dijkstra s Correctness Analysis Breadth-irst Pro. Manolis Kellis March,

More information

Note that M i,j depends on two entries in row (i 1). If we proceed in a row major order, these two entries will be available when we are ready to comp

Note that M i,j depends on two entries in row (i 1). If we proceed in a row major order, these two entries will be available when we are ready to comp CSE 3500 Algorithms and Complexity Fall 2016 Lecture 18: October 27, 2016 Dynamic Programming Steps involved in a typical dynamic programming algorithm are: 1. Identify a function such that the solution

More information

Chapter 8 Dynamic Programming

Chapter 8 Dynamic Programming Chapter 8 Dynamic Programming Copyright 007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by

More information

Analysis of Algorithms I: All-Pairs Shortest Paths

Analysis of Algorithms I: All-Pairs Shortest Paths Analysis of Algorithms I: All-Pairs Shortest Paths Xi Chen Columbia University The All-Pairs Shortest Paths Problem. Input: A directed weighted graph G = (V, E) with an edge-weight function w : E R. Output:

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 21 Single-Source Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Single-Source

More information

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem ORIE 633 Network Flows August 30, 2007 Lecturer: David P. Williamson Lecture 3 Scribe: Gema Plaza-Martínez 1 Polynomial-time algorithms for the maximum flow problem 1.1 Introduction Let s turn now to considering

More information

Lecture 13: Polynomial-Time Algorithms for Min Cost Flows. (Reading: AM&O Chapter 10)

Lecture 13: Polynomial-Time Algorithms for Min Cost Flows. (Reading: AM&O Chapter 10) Lecture 1: Polynomial-Time Algorithms for Min Cost Flows (Reading: AM&O Chapter 1) Polynomial Algorithms for Min Cost Flows Improvements on the two algorithms for min cost flow: Successive Shortest Path

More information

Chapter 8 Dynamic Programming

Chapter 8 Dynamic Programming Chapter 8 Dynamic Programming Copyright 2007 Pearson Addison-Wesley. All rights reserved. Dynamic Programming Dynamic Programming is a general algorithm design technique for solving problems defined by

More information

Chapter 9: Relations Relations

Chapter 9: Relations Relations Chapter 9: Relations 9.1 - Relations Definition 1 (Relation). Let A and B be sets. A binary relation from A to B is a subset R A B, i.e., R is a set of ordered pairs where the first element from each pair

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Spring 207 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 8 March 28, 207 Chandra Chekuri (UIUC) CS374 Spring 207 / 56 Part I Shortest Paths

More information

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees , 2009 Lecture 5: Shortest Paths & Spanning Trees University of Twente m.uetz@utwente.nl wwwhome.math.utwente.nl/~uetzm/dw/ Shortest Path Problem "#$%&'%()*%"()$#+,&- Given directed "#$%&'()*+,%+('-*.#/'01234564'.*,'7+"-%/8',&'5"4'84%#3

More information

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo

CSE 431/531: Analysis of Algorithms. Dynamic Programming. Lecturer: Shi Li. Department of Computer Science and Engineering University at Buffalo CSE 431/531: Analysis of Algorithms Dynamic Programming Lecturer: Shi Li Department of Computer Science and Engineering University at Buffalo Paradigms for Designing Algorithms Greedy algorithm Make a

More information

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source

More information

Shortest paths with negative lengths

Shortest paths with negative lengths Chapter 8 Shortest paths with negative lengths In this chapter we give a linear-space, nearly linear-time algorithm that, given a directed planar graph G with real positive and negative lengths, but no

More information

NAME: Be clear and concise. You may use the number of points assigned toeach problem as a rough

NAME: Be clear and concise. You may use the number of points assigned toeach problem as a rough CS170 Second Midterm 28 Oct 1999 NAME: TA: Be clear and concise. You may use the number of points assigned toeach problem as a rough estimate for the number of minutes you want to allocate to the problem.

More information

The Budget-Constrained Maximum Flow Problem

The Budget-Constrained Maximum Flow Problem 9 The Budget-Constrained Maximum Flow Problem In this chapter we consider the following problem which is called the constrained maximum flow problem ( Cmfp) [AO95]: We are given a budget B and we seek

More information

Combinatorial Optimization

Combinatorial Optimization Combinatorial Optimization Problem set 8: solutions 1. Fix constants a R and b > 1. For n N, let f(n) = n a and g(n) = b n. Prove that f(n) = o ( g(n) ). Solution. First we observe that g(n) 0 for all

More information

Flows. Chapter Circulations

Flows. Chapter Circulations Chapter 4 Flows For a directed graph D = (V,A), we define δ + (U) := {(u,v) A : u U,v / U} as the arcs leaving U and δ (U) := {(u,v) A u / U,v U} as the arcs entering U. 4. Circulations In a directed graph

More information

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) The final exam will be on Thursday, May 12, from 8:00 10:00 am, at our regular class location (CSI 2117). It will be closed-book and closed-notes, except

More information

CS 241 Analysis of Algorithms

CS 241 Analysis of Algorithms CS 241 Analysis of Algorithms Professor Eric Aaron Lecture T Th 9:00am Lecture Meeting Location: OLB 205 Business Grading updates: HW5 back today HW7 due Dec. 10 Reading: Ch. 22.1-22.3, Ch. 25.1-2, Ch.

More information

Maximum flow problem (part I)

Maximum flow problem (part I) Maximum flow problem (part I) Combinatorial Optimization Giovanni Righini Università degli Studi di Milano Definitions A flow network is a digraph D = (N,A) with two particular nodes s and t acting as

More information

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths Lecture. Single-Source Shortest Paths All-Pairs Shortest Paths T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to, rd Edition, MIT Press, 009 Sungkyunkwan University Hyunseung Choo choo@skku.edu

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Fall 205 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 7 October 22, 205 Chandra & Manoj (UIUC) CS374 Fall 205 / 54 Part I Shortest Paths with

More information

Partha Sarathi Mandal

Partha Sarathi Mandal MA 252: Data Structures and Algorithms Lecture 32 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 information

Relation of Pure Minimum Cost Flow Model to Linear Programming

Relation of Pure Minimum Cost Flow Model to Linear Programming Appendix A Page 1 Relation of Pure Minimum Cost Flow Model to Linear Programming The Network Model The network pure minimum cost flow model has m nodes. The external flows given by the vector b with m

More information

Mathematics for Decision Making: An Introduction. Lecture 8

Mathematics for Decision Making: An Introduction. Lecture 8 Mathematics for Decision Making: An Introduction Lecture 8 Matthias Köppe UC Davis, Mathematics January 29, 2009 8 1 Shortest Paths and Feasible Potentials Feasible Potentials Suppose for all v V, there

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 015 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

Maximum flow problem CE 377K. February 26, 2015

Maximum flow problem CE 377K. February 26, 2015 Maximum flow problem CE 377K February 6, 05 REVIEW HW due in week Review Label setting vs. label correcting Bellman-Ford algorithm Review MAXIMUM FLOW PROBLEM Maximum Flow Problem What is the greatest

More information

iretilp : An efficient incremental algorithm for min-period retiming under general delay model

iretilp : An efficient incremental algorithm for min-period retiming under general delay model iretilp : An efficient incremental algorithm for min-period retiming under general delay model Debasish Das, Jia Wang and Hai Zhou EECS, Northwestern University, Evanston, IL 60201 Place and Route Group,

More information

Shortest Paths. CS 320, Fall Dr. Geri Georg, Instructor 320 ShortestPaths 3

Shortest Paths. CS 320, Fall Dr. Geri Georg, Instructor 320 ShortestPaths 3 Shortest Paths CS 320, Fall 2017 Dr. Geri Georg, Instructor georg@colostate.edu 320 ShortestPaths 3 Preliminaries Weighted, directed graphs Weight function: maps edges to real numbers Shortest path weight:

More information

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 6. Dynamic Programming. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 6 Dynamic Programming Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 6.8 Shortest Paths Shortest Paths Shortest path problem. Given a directed graph G = (V,

More information

A NOTE ON STRATEGY ELIMINATION IN BIMATRIX GAMES

A NOTE ON STRATEGY ELIMINATION IN BIMATRIX GAMES A NOTE ON STRATEGY ELIMINATION IN BIMATRIX GAMES Donald E. KNUTH Department of Computer Science. Standford University. Stanford2 CA 94305. USA Christos H. PAPADIMITRIOU Department of Computer Scrence and

More information

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4 CS 0/58,, Biconnectivity Let G = (N,E) be a connected A node a N is an articulation point if there are v and w different from a such that every path from 0 9 8 3 5 7 6 David Maier Biconnected Component

More information

A Polynomial-Time Algorithm to Find Shortest Paths with Recourse

A Polynomial-Time Algorithm to Find Shortest Paths with Recourse A Polynomial-Time Algorithm to Find Shortest Paths with Recourse J. Scott Provan Department of Operations Research University of North Carolina Chapel Hill, NC 7599-380 December, 00 Abstract The Shortest

More information

6.889 Lecture 4: Single-Source Shortest Paths

6.889 Lecture 4: Single-Source Shortest Paths 6.889 Lecture 4: Single-Source Shortest Paths Christian Sommer csom@mit.edu September 19 and 26, 2011 Single-Source Shortest Path SSSP) Problem: given a graph G = V, E) and a source vertex s V, compute

More information

Lecture Notes for Chapter 25: All-Pairs Shortest Paths

Lecture Notes for Chapter 25: All-Pairs Shortest Paths Lecture Notes for Chapter 25: All-Pairs Shortest Paths Chapter 25 overview Given a directed graph G (V, E), weight function w : E R, V n. Goal: create an n n matrix of shortest-path distances δ(u,v). Could

More information

Routing Algorithms. CS60002: Distributed Systems. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur

Routing Algorithms. CS60002: Distributed Systems. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Routing Algorithms CS60002: Distributed Systems Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Main Features Table Computation The routing tables must be computed

More information

CSC 373: Algorithm Design and Analysis Lecture 12

CSC 373: Algorithm Design and Analysis Lecture 12 CSC 373: Algorithm Design and Analysis Lecture 12 Allan Borodin February 4, 2013 1 / 16 Lecture 12: Announcements and Outline Announcements Term test 1 in tutorials. Need to use only two rooms due to sickness

More information

Written Qualifying Exam. Spring, Friday, May 22, This is nominally a three hour examination, however you will be

Written Qualifying Exam. Spring, Friday, May 22, This is nominally a three hour examination, however you will be Written Qualifying Exam Theory of Computation Spring, 1998 Friday, May 22, 1998 This is nominally a three hour examination, however you will be allowed up to four hours. All questions carry the same weight.

More information

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov Dynamic Programming Data Structures and Algorithms Andrei Bulatov Algorithms Dynamic Programming 18-2 Weighted Interval Scheduling Weighted interval scheduling problem. Instance A set of n jobs. Job j

More information

Copyright 1972, by the author(s). All rights reserved.

Copyright 1972, by the author(s). All rights reserved. Copyright 1972, by the author(s). All rights reserved. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are

More information

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source Shortest

More information

Informatique Fondamentale IMA S8

Informatique Fondamentale IMA S8 Informatique Fondamentale IMA S8 Cours 4 : graphs, problems and algorithms on graphs, (notions of) NP completeness Laure Gonnord http://laure.gonnord.org/pro/teaching/ Laure.Gonnord@polytech-lille.fr Université

More information

Discrete Optimization 2010 Lecture 3 Maximum Flows

Discrete Optimization 2010 Lecture 3 Maximum Flows Remainder: Shortest Paths Maximum Flows Discrete Optimization 2010 Lecture 3 Maximum Flows Marc Uetz University of Twente m.uetz@utwente.nl Lecture 3: sheet 1 / 29 Marc Uetz Discrete Optimization Outline

More information

Complexity Theory of Polynomial-Time Problems

Complexity Theory of Polynomial-Time Problems Complexity Theory of Polynomial-Time Problems Lecture 1: Introduction, Easy Examples Karl Bringmann and Sebastian Krinninger Audience no formal requirements, but: NP-hardness, satisfiability problem, how

More information

Randomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th

Randomized Sorting Algorithms Quick sort can be converted to a randomized algorithm by picking the pivot element randomly. In this case we can show th CSE 3500 Algorithms and Complexity Fall 2016 Lecture 10: September 29, 2016 Quick sort: Average Run Time In the last lecture we started analyzing the expected run time of quick sort. Let X = k 1, k 2,...,

More information

Lecture 2: Divide and conquer and Dynamic programming

Lecture 2: Divide and conquer and Dynamic programming Chapter 2 Lecture 2: Divide and conquer and Dynamic programming 2.1 Divide and Conquer Idea: - divide the problem into subproblems in linear time - solve subproblems recursively - combine the results in

More information

6. DYNAMIC PROGRAMMING II. sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph

6. DYNAMIC PROGRAMMING II. sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph 6. DYNAMIC PROGRAMMING II sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph Shortest paths Shortest path problem. Given a digraph G = (V, E),

More information

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms

CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms CSC 1700 Analysis of Algorithms: Warshall s and Floyd s algorithms Professor Henry Carter Fall 2016 Recap Space-time tradeoffs allow for faster algorithms at the cost of space complexity overhead Dynamic

More information

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional)

Section Summary. Sequences. Recurrence Relations. Summations Special Integer Sequences (optional) Section 2.4 Section Summary Sequences. o Examples: Geometric Progression, Arithmetic Progression Recurrence Relations o Example: Fibonacci Sequence Summations Special Integer Sequences (optional) Sequences

More information

A faster algorithm for the single source shortest path problem with few distinct positive lengths

A faster algorithm for the single source shortest path problem with few distinct positive lengths A faster algorithm for the single source shortest path problem with few distinct positive lengths J. B. Orlin, K. Madduri, K. Subramani, and M. Williamson Journal of Discrete Algorithms 8 (2010) 189 198.

More information

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: 2017 2018 Time Allowed 2 Hours INSTRUCTIONS TO STUDENTS 1. This assessment consists of Eight (8) questions and comprises

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes

More information

Econ 172A, Fall 2012: Final Examination Solutions (I) 1. The entries in the table below describe the costs associated with an assignment

Econ 172A, Fall 2012: Final Examination Solutions (I) 1. The entries in the table below describe the costs associated with an assignment Econ 172A, Fall 2012: Final Examination Solutions (I) 1. The entries in the table below describe the costs associated with an assignment problem. There are four people (1, 2, 3, 4) and four jobs (A, B,

More information

Chapter 7 Network Flow Problems, I

Chapter 7 Network Flow Problems, I Chapter 7 Network Flow Problems, I Network flow problems are the most frequently solved linear programming problems. They include as special cases, the assignment, transportation, maximum flow, and shortest

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J LECTURE 14 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Charles E. Leiserson Paths in graphs

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/8.40J/SMA550 Lecture 7 Prof. Erik Demaine Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v v L v k is defined

More information

6. DYNAMIC PROGRAMMING II

6. DYNAMIC PROGRAMMING II 6. DYNAMIC PROGRAMMING II sequence alignment Hirschberg's algorithm Bellman-Ford algorithm distance vector protocols negative cycles in a digraph Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison

More information

CS261: A Second Course in Algorithms Lecture #12: Applications of Multiplicative Weights to Games and Linear Programs

CS261: A Second Course in Algorithms Lecture #12: Applications of Multiplicative Weights to Games and Linear Programs CS26: A Second Course in Algorithms Lecture #2: Applications of Multiplicative Weights to Games and Linear Programs Tim Roughgarden February, 206 Extensions of the Multiplicative Weights Guarantee Last

More information

1 Review of Vertex Cover

1 Review of Vertex Cover CS266: Parameterized Algorithms and Complexity Stanford University Lecture 3 Tuesday, April 9 Scribe: Huacheng Yu Spring 2013 1 Review of Vertex Cover In the last lecture, we discussed FPT algorithms for

More information

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes Analysis of Algorithms Single Source Shortest Path Andres Mendez-Vazquez November 9, 01 1 / 108 Outline 1 Introduction Introduction and Similar Problems General Results Optimal Substructure Properties

More information

On the Exponent of the All Pairs Shortest Path Problem

On the Exponent of the All Pairs Shortest Path Problem On the Exponent of the All Pairs Shortest Path Problem Noga Alon Department of Mathematics Sackler Faculty of Exact Sciences Tel Aviv University Zvi Galil Department of Computer Science Sackler Faculty

More information

Solutions to Exercises

Solutions to Exercises 1/13 Solutions to Exercises The exercises referred to as WS 1.1(a), and so forth, are from the course book: Williamson and Shmoys, The Design of Approximation Algorithms, Cambridge University Press, 2011,

More information

Determine the size of an instance of the minimum spanning tree problem.

Determine the size of an instance of the minimum spanning tree problem. 3.1 Algorithm complexity Consider two alternative algorithms A and B for solving a given problem. Suppose A is O(n 2 ) and B is O(2 n ), where n is the size of the instance. Let n A 0 be the size of the

More information

Breadth-First Search of Graphs

Breadth-First Search of Graphs Breadth-First Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of Breadth-First Search of Graphs a) Single Source

More information

Discrete Optimization Lecture 5. M. Pawan Kumar

Discrete Optimization Lecture 5. M. Pawan Kumar Discrete Optimization Lecture 5 M. Pawan Kumar pawan.kumar@ecp.fr Exam Question Type 1 v 1 s v 0 4 2 1 v 4 Q. Find the distance of the shortest path from s=v 0 to all vertices in the graph using Dijkstra

More information

Econ 172A, Fall 2012: Final Examination Solutions (II) 1. The entries in the table below describe the costs associated with an assignment

Econ 172A, Fall 2012: Final Examination Solutions (II) 1. The entries in the table below describe the costs associated with an assignment Econ 172A, Fall 2012: Final Examination Solutions (II) 1. The entries in the table below describe the costs associated with an assignment problem. There are four people (1, 2, 3, 4) and four jobs (A, B,

More information

REVISION SHEET DECISION MATHS 2 DECISION ANALYSIS

REVISION SHEET DECISION MATHS 2 DECISION ANALYSIS REVISION SHEET DECISION MATHS 2 DECISION ANALYSIS The main ideas are covered in AQA Edexcel MEI OCR D2 Before the exam you should know The meaning of the different kinds of node. Be able to construct a

More information

Limitations of Algorithm Power

Limitations of Algorithm Power Limitations of Algorithm Power Objectives We now move into the third and final major theme for this course. 1. Tools for analyzing algorithms. 2. Design strategies for designing algorithms. 3. Identifying

More information

Find: a multiset M { 1,..., n } so that. i M w i W and. i M v i is maximized. Find: a set S { 1,..., n } so that. i S w i W and. i S v i is maximized.

Find: a multiset M { 1,..., n } so that. i M w i W and. i M v i is maximized. Find: a set S { 1,..., n } so that. i S w i W and. i S v i is maximized. Knapsack gain Slides for IS 675 PV hapter 6: ynamic Programming, Part 2 Jim Royer EES October 28, 2009 The Knapsack Problem (KP) knapsack with weight capacity W. Items 1,..., n where item i has weight

More information

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Breadth First Search, Dijkstra s Algorithm for Shortest Paths CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth

More information

Graphs and Network Flows IE411. Lecture 15. Dr. Ted Ralphs

Graphs and Network Flows IE411. Lecture 15. Dr. Ted Ralphs Graphs and Network Flows IE411 Lecture 15 Dr. Ted Ralphs IE411 Lecture 15 1 Preflow-Push Algorithms First developed by A. V. Goldberg in 1985. Best preflow-push algorithms outperform best augmenting path

More information

Lecture 7: Dynamic Programming I: Optimal BSTs

Lecture 7: Dynamic Programming I: Optimal BSTs 5-750: Graduate Algorithms February, 06 Lecture 7: Dynamic Programming I: Optimal BSTs Lecturer: David Witmer Scribes: Ellango Jothimurugesan, Ziqiang Feng Overview The basic idea of dynamic programming

More information

CMPSCI 611 Advanced Algorithms Midterm Exam Fall 2015

CMPSCI 611 Advanced Algorithms Midterm Exam Fall 2015 NAME: CMPSCI 611 Advanced Algorithms Midterm Exam Fall 015 A. McGregor 1 October 015 DIRECTIONS: Do not turn over the page until you are told to do so. This is a closed book exam. No communicating with

More information

Shortest Path Algorithms

Shortest Path Algorithms Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path 2 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node

More information

GRAPH ALGORITHMS Week 3 (16-21 October 2017)

GRAPH ALGORITHMS Week 3 (16-21 October 2017) GRAPH ALGORITHMS Week 3 (16-21 October 2017) C. Croitoru croitoru@info.uaic.ro FII October 15, 2017 1 / 63 OUTLINE Graph Theory Vocabulary 1 Definition of a Graph 2 Variations in the Definition of a Graph

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 21: Introduction to NP-Completeness 12/9/2015 Daniel Bauer Algorithms and Problem Solving Purpose of algorithms: find solutions to problems. Data Structures provide ways

More information

Lecture 8: Complete Problems for Other Complexity Classes

Lecture 8: Complete Problems for Other Complexity Classes IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Basic Course on Computational Complexity Lecture 8: Complete Problems for Other Complexity Classes David Mix Barrington and Alexis Maciel

More information

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

CSC Design and Analysis of Algorithms. LP Shader Electronics Example CSC 80- Design and Analysis of Algorithms Lecture (LP) LP Shader Electronics Example The Shader Electronics Company produces two products:.eclipse, a portable touchscreen digital player; it takes hours

More information

III. Linear Programming

III. Linear Programming III. Linear Programming Thomas Sauerwald Easter 2017 Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J LECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Erik Demaine November 14, 005 Copyright

More information

CS173 Lecture B, November 3, 2015

CS173 Lecture B, November 3, 2015 CS173 Lecture B, November 3, 2015 Tandy Warnow November 3, 2015 CS 173, Lecture B November 3, 2015 Tandy Warnow Announcements Examlet 7 is a take-home exam, and is due November 10, 11:05 AM, in class.

More information

ACM-ICPC South Western European Regional SWERC 2008

ACM-ICPC South Western European Regional SWERC 2008 ACM-ICPC South Western European Regional SWERC 2008 FAU Contest Team icpc@i2.informatik.uni-erlangen.de Friedrich-Alexander Universität Erlangen-Nürnberg November, 23 2008 FAU Contest Team ACM-ICPC South

More information

Max-plus algebra. Max-plus algebra. Monika Molnárová. Technická univerzita Košice. Max-plus algebra.

Max-plus algebra. Max-plus algebra. Monika Molnárová. Technická univerzita Košice. Max-plus algebra. Technická univerzita Košice monika.molnarova@tuke.sk Outline 1 Digraphs Maximum cycle-mean and transitive closures of a matrix Reducible and irreducible matrices Definite matrices Digraphs Complete digraph

More information

Network Flows. 6. Lagrangian Relaxation. Programming. Fall 2010 Instructor: Dr. Masoud Yaghini

Network Flows. 6. Lagrangian Relaxation. Programming. Fall 2010 Instructor: Dr. Masoud Yaghini In the name of God Network Flows 6. Lagrangian Relaxation 6.3 Lagrangian Relaxation and Integer Programming Fall 2010 Instructor: Dr. Masoud Yaghini Integer Programming Outline Branch-and-Bound Technique

More information

Basic Test. To show three vectors are independent, form the system of equations

Basic Test. To show three vectors are independent, form the system of equations Sample Quiz 7 Sample Quiz 7, Problem. Independence The Problem. In the parts below, cite which tests apply to decide on independence or dependence. Choose one test and show complete details. (a) Vectors

More information

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro. CMPS 00 Fall 01 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with edge-weight function

More information

Linear Equations in Linear Algebra

Linear Equations in Linear Algebra 1 Linear Equations in Linear Algebra 1.1 SYSTEMS OF LINEAR EQUATIONS LINEAR EQUATION,, 1 n A linear equation in the variables equation that can be written in the form a a a b 1 1 2 2 n n a a is an where

More information

6. DYNAMIC PROGRAMMING I

6. DYNAMIC PROGRAMMING I 6. DYNAMIC PROGRAMMING I weighted interval scheduling segmented least squares knapsack problem RNA secondary structure Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013

More information

Combinatorial optimization problems

Combinatorial optimization problems Combinatorial optimization problems Heuristic Algorithms Giovanni Righini University of Milan Department of Computer Science (Crema) Optimization In general an optimization problem can be formulated as:

More information

Numerical Solution Techniques in Mechanical and Aerospace Engineering

Numerical Solution Techniques in Mechanical and Aerospace Engineering Numerical Solution Techniques in Mechanical and Aerospace Engineering Chunlei Liang LECTURE 3 Solvers of linear algebraic equations 3.1. Outline of Lecture Finite-difference method for a 2D elliptic PDE

More information

5. Solving the Bellman Equation

5. Solving the Bellman Equation 5. Solving the Bellman Equation In the next two lectures, we will look at several methods to solve Bellman s Equation (BE) for the stochastic shortest path problem: Value Iteration, Policy Iteration and

More information

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash

CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash CS 781 Lecture 9 March 10, 2011 Topics: Local Search and Optimization Metropolis Algorithm Greedy Optimization Hopfield Networks Max Cut Problem Nash Equilibrium Price of Stability Coping With NP-Hardness

More information