Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Similar documents
7.5 Bipartite Matching

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Algorithm Design and Analysis

Soviet Rail Network, 1955

7. NETWORK FLOW II. bipartite matching disjoint paths extensions to max flow 3D Memory Reliability survey design airline scheduling image segmentation

Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2019

Algorithms and Theory of Computation. Lecture 11: Network Flow

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Algorithms: Lecture 12. Chalmers University of Technology

Two Applications of Maximum Flow

Maximum flow problem

5 Flows and cuts in digraphs

1 Matchings in Non-Bipartite Graphs

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

6.046 Recitation 11 Handout

GRAPH ALGORITHMS Week 7 (13 Nov - 18 Nov 2017)

CS 138b Computer Algorithm Homework #14. Ling Li, February 23, Construct the level graph

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

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

. CS711008Z Algorithm Design and Analysis. Lecture 10. Algorithm design technique: Network flow and its applications 1. Dongbo Bu

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

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

Discrete Optimization 23

Chapter 7. Network Flow. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Breadth-First Search of Graphs

CSC 373: Algorithm Design and Analysis Lecture 12

Lexicographic Flow. Dexter Kozen Department of Computer Science Cornell University Ithaca, New York , USA. June 25, 2009

10 Max-Flow Min-Cut Flows and Capacitated Graphs 10 MAX-FLOW MIN-CUT

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

Maximum flow problem CE 377K. February 26, 2015

Chapter 8. NP and Computational Intractability

Algorithms: COMP3121/3821/9101/9801

RECAP How to find a maximum matching?

Network Flows. CTU FEE Department of control engineering. March 28, 2017

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

Mathematics for Decision Making: An Introduction. Lecture 13

The min cost flow problem Course notes for Optimization Spring 2007

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

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

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 7 Network Flow Problems, I

Linear and Integer Programming - ideas

The min cost flow problem Course notes for Search and Optimization Spring 2004

Algorithm Design and Analysis

Maximum Flow. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Maximum Flow 1 / 27

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

Flow Network. The following figure shows an example of a flow network:

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Maximum flow problem (part I)

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

Lecture 8 Network Optimization Algorithms

Friday, September 21, Flows

2. ALGORITHM ANALYSIS

Combinatorial Optimization

Running Time. Assumption. All capacities are integers between 1 and C.

Parallel Graph Algorithms (con4nued)

Discrete Optimization 2010 Lecture 3 Maximum Flows

Max Flow: Algorithms and Applications

Algorithm Design and Analysis

2.1 Computational Tractability. Chapter 2. Basics of Algorithm Analysis. Computational Tractability. Polynomial-Time

Maximum Integer Flows in Directed Planar Graphs with Multiple Sources and Sinks and Vertex Capacities

Introduction to Graph Theory

ACO Comprehensive Exam March 20 and 21, Computability, Complexity and Algorithms

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

Polynomial-Time Reductions

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Parallel Graph Algorithms (con4nued)

Nowhere zero flow. Definition: A flow on a graph G = (V, E) is a pair (D, f) such that. 1. D is an orientation of G. 2. f is a function on E.

Algorithm Design and Analysis

Types of Networks. Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas

NP and Computational Intractability

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Algorithm Design and Analysis

CSCE423/823. Introduction. Flow Networks. Ford-Fulkerson Method. Edmonds-Karp Algorithm. Maximum Bipartite Matching 2/35 CSCE423/823.

1 T 1 = where 1 is the all-ones vector. For the upper bound, let v 1 be the eigenvector corresponding. u:(u,v) E v 1(u)

Algorithms Demands and Bounds. Demands and Bounds. Design and Analysis of Algorithms Andrei Bulatov

12. LOCAL SEARCH. gradient descent Metropolis algorithm Hopfield neural networks maximum cut Nash equilibria

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

Minimum cost transportation problem

Linear Programming Duality P&S Chapter 3 Last Revised Nov 1, 2004

Maximum Flow. Reading: CLRS Chapter 26. CSE 6331 Algorithms Steve Lai

New Exact and Approximation Algorithms for the Star Packing Problem in Undirected Graphs

Network Flows. 4. Maximum Flows Problems. Fall 2010 Instructor: Dr. Masoud Yaghini

Copyright 2000, Kevin Wayne 1

8.5 Sequencing Problems

Reductions. Reduction. Linear Time Reduction: Examples. Linear Time Reductions

Week 4. (1) 0 f ij u ij.

M-saturated M={ } M-unsaturated. Perfect Matching. Matchings

6. DYNAMIC PROGRAMMING II

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Transcription:

Chapter 7 Network Flow Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

7.5 Bipartite Matching

Matching Matching. Input: undirected graph G = (V, E). M E is a matching if each node appears in at most one edge in M. Max matching: find a max cardinality matching.

Bipartite Matching Bipartite matching. Input: undirected, bipartite graph G = (L R, E). M E is a matching if each node appears in at most one edge in M. Max matching: find a max cardinality matching. ' 2 2' ' matching -2', -', -5' ' L 5 5' R

Bipartite Matching Bipartite matching. Input: undirected, bipartite graph G = (L R, E). M E is a matching if each node appears in at most one edge in M. Max matching: find a max cardinality matching. ' 2 2' ' max matching -', 2-2', -' -' ' L 5 5' R 5

Bipartite Matching Max flow formulation. Create digraph G' = (L R {s, t}, E' ). Direct all edges from L to R, and assign unit (or infinite) capacity. Add source s, and unit capacity edges from s to each node in L. Add sink t, and unit capacity edges from each node in R to t. G' ' 2 2' s ' t ' L 5 5' R 6

Bipartite Matching: Proof of Correctness Theorem. Max cardinality matching in G = value of max flow in G'. Pf. Given max matching M of cardinality k. Consider flow f that sends unit along each of k paths. f is a flow, and has value at least k. ' ' 2 2' 2 2' ' s ' t ' ' G 5 5' 5 5' G' 7

Bipartite Matching: Proof of Correctness Theorem. Max cardinality matching in G = value of max flow in G'. Pf. Let f be a max flow in G' of value k. Integrality theorem k is integral and can assume f is 0-. Consider M = set of edges from L to R with f(e) =. each node in L and R participates in at most one edge in M M = k: consider cut (L s, R t) ' ' 2 2' 2 2' s ' t ' ' ' G' 5 5' 5 5' G 8

Bipartite Matching: Running Time Which max flow algorithm to use for bipartite matching? Generic augmenting path: O(m val(f*) ) = O(mn). Capacity scaling: O(m 2 log C ) = O(m 2 ). Shortest augmenting path: O(m n /2 ). Which max flow algorithm to use for Non-bipartite matching? Structure of non-bipartite graphs is more complicated, but well-understood. [Tutte-Berge, Edmonds-Galai] Blossom algorithm: O(n ). [Edmonds 965] Best known: O(m n /2 ). [Micali-Vazirani 980] 9

7.6 Disjoint Paths

Edge Disjoint Paths Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. 2 5 s 6 t 7

Edge Disjoint Paths Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths. Def. Two paths are edge-disjoint if they have no edge in common. Ex: communication networks. 2 5 s 6 t 7 2

Edge Disjoint Paths Max flow formulation: assign unit capacity to every edge. s t Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf. Suppose there are k edge-disjoint paths P,..., P k. Set f(e) = if e participates in some path P i ; else set f(e) = 0. Since paths are edge-disjoint, f is a flow of value k.

Edge Disjoint Paths Max flow formulation: assign unit capacity to every edge. s t Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf. Suppose max flow value is k. Integrality theorem there exists 0- flow f of value k. Consider edge (s, u) with f(s, u) =. by conservation, there exists an edge (u, v) with f(u, v) = continue until reach t, always choosing a new edge Produces k (not necessarily simple) edge-disjoint paths. can eliminate cycles to get simple paths if desired

Network Connectivity Network connectivity. Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s. Def. A set of edges F E disconnects t from s if all s-t paths uses at least one edge in F. 2 5 s 6 t 7 5

Edge Disjoint Paths and Network Connectivity Theorem. [Menger 927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf. Suppose the removal of F E disconnects t from s, and F = k. All s-t paths use at least one edge of F. Hence, the number of edgedisjoint paths is at most k. 2 5 2 5 s 6 t s 6 t 7 7 6

Disjoint Paths and Network Connectivity Theorem. [Menger 927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf. Suppose max number of edge-disjoint paths is k. Then max flow value is k. Max-flow min-cut cut (A, B) of capacity k. Let F be set of edges going from A to B. F = k and disconnects t from s. A 2 5 2 5 s 6 t s 6 t 7 7 7

7. Project Selection

Project Selection Projects with prerequisites. can be positive or negative Set P of possible projects. Project v has associated revenue p v. some projects generate money: create interactive e-commerce interface, redesign web page others cost money: upgrade computers, get site license Set of prerequisites E. If (v, w) E, can't do project v and unless also do project w. A subset of projects A P is feasible if the prerequisite of every project in A also belongs to A. Project selection. Choose a feasible subset of projects to maximize revenue: p v v A 9

Project Selection: Prerequisite Graph Prerequisite graph. Include an edge from v to w if can't do v without also doing w. {v, w, x} is feasible subset of projects. {v, x} is infeasible subset of projects. w w v x v x feasible infeasible 20

Project Selection: Min Cut Formulation Min cut formulation. Assign capacity to all prerequisite edge. Add edge (s, v) with capacity -p v if p v > 0. Add edge (v, t) with capacity -p v if p v < 0. For notational convenience, define p s = p t = 0. p u u w -p w s p y y z -p z t p v -p x v x 2

Project Selection: Min Cut Formulation Claim. (A, B) is min cut iff A { s } is optimal set of projects. Infinite capacity edges ensure A { s } is feasible. Max revenue because: cap(a, B) = p v v B: p v > 0 = p v - v: p v > 0!" # constant + ( p v ) v A: p v < 0 p v v A w u s A p u p y y z -p w t p v v x -p x 22

Example: Open Pit Mining Open-pit mining. (studied since early 960s) Blocks of earth are extracted from surface to retrieve ore. Each block v has net value p v = value of ore - processing cost. Can't remove block v before w or x. w v x 2

7.7 Extensions to Max Flow

Circulation with Demands Circulation with demands. Directed graph G = (V, E). Edge capacities c(e), e E. Node supply and demands d(v), v V. demand if d(v) > 0; supply if d(v) < 0; transshipment if d(v) = 0 Def. A circulation is a function f that satisfies: For each e E: 0 f(e) c(e) (capacity) For each v V: f (e) - f (e) = d(v) (conservation) e in to v e out of v Circulation problem: given (G, c, d), does there exist a circulation? 25

Circulation with Demands Necessary condition: sum of supplies = sum of demands. d(v) v : d (v) > 0 = d(v) v : d (v) < 0 =: D Pf. Sum conservation constraints for every demand node v. -8-6 supply -7 0 6 6 6 7 7 2 7 9 0 0 capacity demand flow 26

Circulation with Demands Max flow formulation. -8-6 supply G: 7 7-7 0 6 9 0 0 demand 27

Circulation with Demands Max flow formulation. Add new source s and sink t. For each v with d(v) < 0, add edge (s, v) with capacity -d(v). For each v with d(v) > 0, add edge (v, t) with capacity d(v). Claim: G has circulation iff G' has max flow of value D. s saturates all edges leaving s and entering t 7 8 6 supply G': 7 7 0 6 9 0 0 demand t 28

Circulation with Demands Integrality theorem. If all capacities and demands are integers, and there exists a circulation, then there exists one that is integer-valued. Pf. Follows from max flow formulation and integrality theorem for max flow. Characterization. Given (G, c, d), there does not exist a circulation iff there exists a node partition (A, B) such that Σ v B d(v) > cap(a, B) Pf idea. Look at min cut in G'. demand by nodes in B exceeds supply of nodes in B plus max capacity of edges going from A to B 29

Circulation with Demands and Lower Bounds Feasible circulation. Directed graph G = (V, E). Edge capacities c(e) and lower bounds l(e), e E. Node supply and demands d(v), v V. Def. A circulation is a function that satisfies: For each e E: l(e) f(e) c(e) (capacity) For each v V: f (e) - f (e) = d(v) (conservation) e in to v e out of v Circulation problem with lower bounds. Given (G, l, c, d), does there exists a circulation? 0

Circulation with Demands and Lower Bounds Idea. Model lower bounds with demands. Send l(e) units of flow along edge e. Update demands of both endpoints. lower bound upper bound capacity v [2, 9] w d(v) d(w) d(v) + 2 d(w) - 2 G G' v 7 w Theorem. There exists a circulation in G iff there exists a circulation in G'. If all demands, capacities, and lower bounds in G are integers, then there is a circulation in G that is integer-valued. Pf sketch. f(e) is a circulation in G iff f'(e) = f(e) - l(e) is a circulation in G'.

Census Tabulation ( Exercise 7.9 ) Feasible matrix rounding. Given a p-by-q matrix D = {d ij } of real numbers. Row i sum = a i, column j sum = b j. Round each d ij, a i, b j up or down to integer so that sum of rounded elements in each row (column) equals row (column) sum. Original application: publishing US Census data. Goal. Find a feasible rounding, if one exists.. 6.8 7. 7.2 7 7 7 9.6 2. 0.7 2.7 0 2.6.2 6.5. 7 6. 0..5 6 0 5 original matrix feasible rounding 2

Census Tabulation Feasible matrix rounding. Given a p-by-q matrix D = {d ij } of real numbers. Row i sum = a i, column j sum = b j. Round each d ij, a i, b j up or down to integer so that sum of rounded elements in each row (column) equals row (column) sum. Original application: publishing US Census data. Goal. Find a feasible rounding, if one exists. Remark. "Threshold rounding" can fail. 0.5 0.5 0.5.05 0 0 0.55 0.55 0.55.65 0 2 0.9 0.9 0.9 original matrix feasible rounding

Census Tabulation Theorem. Feasible matrix rounding always exists. Pf. Formulate as a circulation problem with lower bounds. Original data provides circulation (all demands = 0). Integrality theorem integral solution feasible rounding. [ 0, ] lower bound upper bound. 6.8 7. 9.6 2. 0.7.6.2 6.5 7.2 2.7. [7, 8] [, ] [6, 7] [9, 0] [7, 8] ' [6, 7] 6. 0..5 s [2, ] 2 [2, ] 2' [0, ] t [, 2] [, ] [, 2] [6, 7] [0, ] ' [, 5] row column

Census Tabulation Theorem. Feasible matrix rounding always exists. Pf. Formulate as a circulation problem with lower bounds. Original data provides circulation (all demands = 0). Integrality theorem integral solution feasible rounding. [ max{ a i, b j }, i j min{ a i, b i j j } ] lower bound upper bound d d 2 d a d 2 d 22 d 2 a2 [ a, a ] [ d, d ] ' [ b 6, 7, b ] d d 2 d a b b 2 b s [ a 2, a 2 ] 2 2' [ b0, 2, b 2 ] t [ a, a ] [ b,, b 5 ] [ d, d ] ' row column 5

7.8 Survey Design

Survey Design Survey design. Design survey asking n c consumers about n p products. Can only survey consumer i about a product j if he owns it. Ask consumer i between c i and c i ' questions. Ask between p j and p j ' consumers about product j. Goal. Design a survey that meets these specs, if possible. 7

Survey Design Algorithm. Formulate as a circulation problem with lower bounds. Include an edge (i, j) if customer i owns product j. Integer circulation feasible survey design. (t,s) makes sure problem has a circulation. [ max{ i c i, j p j }, min{ i or [ 0, ] c i, p j } ] j [c, c '] 0 [0, ] [0, ] ' 0 [p, p '] [c 2, c 2 '] 2 0 [0, ] [0, ] [0, ] 2' 0 [p 2, p 2 '] s [c, c '] consumers 0 0 0 [c 0, c '] [0, ] [p, p '] 0 [0, ] [0, ] ' ' 0 0 5' [p, p '] [p 5, p 5 '] products t 8

Chapter 7 Network Flow Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 9