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

Slides:



Advertisements
Similar presentations
Lecture 7. Network Flows We consider a network with directed edges. Every edge has a capacity. If there is an edge from i to j, there is an edge from.
Advertisements

Introduction to Algorithms
15.082J & 6.855J & ESD.78J October 14, 2010 Maximum Flows 2.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
1 Maximum flow sender receiver Capacity constraint Lecture 6: Jan 25.
EMIS 8374 Vertex Connectivity Updated 20 March 2008.
CSE 421 Algorithms Richard Anderson Lecture 23 Network Flow Applications.
Basic Feasible Solutions: Recap MS&E 211. WILL FOLLOW A CELEBRATED INTELLECTUAL TEACHING TRADITION.
COMP 482: Design and Analysis of Algorithms
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lectures on Network Flows
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
7.7 Extensions to Max Flow. 2 Circulation with Demands Circulation with demands. n Directed graph G = (V, E). n Edge capacities c(e), e  E. n Node supply.
Maximum Flows Lecture 4: Jan 19. Network transmission Given a directed graph G A source node s A sink node t Goal: To send as much information from s.
Maximum Flow Applications
Applications of Network Flow Problem. 7.5 Bipartite Matching.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Lecture 11. Matching A set of edges which do not share a vertex is a matching. Application: Wireless Networks may consist of nodes with single radios,
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
CSEP 521 Applied Algorithms
15.082J and 6.855J and ESD.78J November 2, 2010 Network Flow Duality and Applications of Network Flows.
15.082J, 6.855J, and ESD.78J September 21, 2010 Eulerian Walks Flow Decomposition and Transformations.
1 Linear Programming & Flows Instructor: YE, Deshi
Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 26.
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network.
1 Linear Programming & Flows Instructor: yedeshi
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Applications of the Max-Flow Min-Cut Theorem. S-T Cuts SF D H C A NY S = {SF, D, H}, T={C,A,NY} [S,T] = {(D,A),(D,C),(H,A)}, Cap [S,T] =
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
10. Lecture WS 2006/07Bioinformatics III1 V10: Network Flows V10 follows closely chapter 12.1 in on „Flows and Cuts in Networks and Chapter 12.2 on “Solving.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
Maximum Flow Problem (Thanks to Jim Orlin & MIT OCW)
Chapter 7 April 28 Network Flow.
15.082J and 6.855J March 4, 2003 Introduction to Maximum Flows.
Network Flow Analysis of Algorithms.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
and 6.855J March 6, 2003 Maximum Flows 2. 2 Network Reliability u Communication Network u What is the maximum number of arc disjoint paths from.
10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 21 Network.
Chapter 7 May 3 Ford-Fulkerson algorithm Step-by-step walk through of an example Worst-case number of augmentations Edmunds-Karp modification Time complexity.
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Data Structures & Algorithms Network Flow Richard Newman based on book by R. Sedgewick.
CSEP 521 Applied Algorithms Richard Anderson Lecture 8 Network Flow.
CSE 421 Algorithms Richard Anderson Lecture 22 Network Flow.
Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
CSE 421 Algorithms Richard Anderson Lecture 24 Network Flow Applications.
Markov Random Fields in Vision
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Algorithm Design and Analysis
Lectures on Network Flows
Richard Anderson Lecture 23 Network Flow
Maximum Flow 9/13/2018 6:12 PM Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015.
Lecture 22 Network Flow, Part 2
Chapter 5. Optimal Matchings
3.3 Applications of Maximum Flow and Minimum Cut
Instructor: Shengyu Zhang
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Network Flow and Connectivity in Wireless Sensor Networks
Max Flow Min Cut, Bipartite Matching Yin Tat Lee
Piyush Kumar (Lecture 6: MaxFlow MinCut Applications)
EE5900 Advanced Embedded System For Smart Infrastructure
and 6.855J March 6, 2003 Maximum Flows 2
Flow Feasibility Problems
Richard Anderson Lecture 23 Network Flow Applications
Lecture 22 Network Flow, Part 2
Presentation transcript:

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

7.5 Bipartite Matching

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

4 Bipartite Matching Bipartite matching. n Input: undirected, bipartite graph G = (L  R, E). – bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint sets (U and V) such that every edge connects a vertex in U to one in V. n M  E is a matching if each node appears in at most one edge in M. n Max matching: find a max cardinality matching ' 3' 5' 2 4 2' 4' matching 1-2', 3-1', 4-5' RL

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

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

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

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

9 Def. A matching M  E is perfect if each node appears in exactly one edge in M. Q. When does a bipartite graph have a perfect matching? Structure of bipartite graphs with perfect matchings. n Clearly we must have |L| = |R|. n What other conditions are necessary? n What conditions are sufficient? Perfect Matching

10 Notation. Let S be a subset of nodes, and let N(S) be the set of nodes adjacent to nodes in S. Observation. If a bipartite graph G = (L  R, E), has a perfect matching, then |N(S)|  |S| for all subsets S  L. Pf. Each node in S has to be matched to a different node in N(S). Perfect Matching No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' } ' 3' 5' 2 4 2' 4' L R

11 Marriage Theorem. [Frobenius 1917, Hall 1935] Let G = (L  R, E) be a bipartite graph with |L| = |R|. Then, G has a perfect matching iff |N(S)|  |S| for all subsets S  L. Pf.  This was the previous observation. Marriage Theorem ' 3' 5' 2 4 2' 4' L R No perfect matching: S = { 2, 4, 5 } N(S) = { 2', 5' }.

12 Pf.  Suppose G does not have a perfect matching. n Formulate as a max flow problem and let (A, B) be min cut in G'. n By max-flow min-cut, cap(A, B) < | L |. n Define L A = L  A, L B = L  B, R A = R  A. n cap(A, B) = | L B | + | R A |. n Since min cut can't use  edges: N(L A )  R A. n |N(L A )|  | R A | = cap(A, B) - | L B | < | L | - | L B | = | L A |. – Choose S = L A, conflict with assumption ▪ Proof of Marriage Theorem L A = {2, 4, 5} L B = {1, 3} R A = {2', 5'} N(L A ) = {2', 5'} s ' 3' 5' t 2 4 4' 1  2' A  G' 

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

7.6 Disjoint Paths

15 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. s Edge Disjoint Paths t

16 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. s Edge Disjoint Paths t

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

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

19 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 every s-t path uses at least one edge in F. Network Connectivity s t

20 Edge Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  n Suppose the removal of F  E disconnects t from s, and |F| = k. n Every s-t path uses at least one edge in F. Hence, the number of edge-disjoint paths is at most k. ▪ s t s t

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

7.7 Extensions to Max Flow

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

24 Necessary condition: sum of supplies = sum of demands. Pf. Sum conservation constraints for every demand node v flow Circulation with Demands capacity demand supply

25 Circulation with Demands Max flow formulation. G: supply demand

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

27 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 (V, E, c, d), there does not exists 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

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

29 Circulation with Demands and Lower Bounds Idea. Model lower bounds with demands. n Send (e) units of flow along edge e. n Update demands of both endpoints. 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) - (e) is a circulation in G'. vw [2, 9] lower bound upper bound vw d(v)d(w) d(v) + 2 d(w) - 2 G G' 7 capacity

7.8 Survey Design

31 Survey Design Survey design. n Design survey asking n 1 consumers about n 2 products. n Can only survey consumer i about product j if they own it. n Ask consumer i between c i and c i ' questions. n Ask between p j and p j ' consumers about product j. Goal. Design a survey that meets these specs, if possible. Bipartite perfect matching. Special case when c i = c i ' = p i = p i ' = 1. one survey question per product

32 Survey Design Algorithm. Formulate as a circulation problem with lower bounds. n Include an edge (i, j) if consumer i owns product j. n Integer circulation  feasible survey design. – Flow on (t,s) is equal to overall # of questions asked – All nodes have demand of 0 s ' 3' 5' t 2 4 2' 4' [c 1, c 1 '] [0, 1] consumers [p 1, p 1 '] [0,  ] products [  ci,  ci’]

7.10 Image Segmentation

34 Image Segmentation Image segmentation. n Central problem in image processing. n Divide image into coherent regions. Ex: Three people standing in front of complex background scene. Identify each person as a coherent object.

35 Image Segmentation Foreground / background segmentation. n Label each pixel in picture as belonging to foreground or background. n V = set of pixels, E = pairs of neighboring pixels. n a i  0 is likelihood pixel i in foreground. n b i  0 is likelihood pixel i in background. n p ij  0 is separation penalty for labeling one of i and j as foreground, and the other as background. Goals. n Accuracy: if a i > b i in isolation, prefer to label i in foreground. n Smoothness: if many neighbors of i are labeled foreground, we should be inclined to label i as foreground. n Find partition (A, B) that maximizes: foreground background

36 Image Segmentation Formulate as min cut problem. n Maximization. n No source or sink. n Undirected graph. Turn into minimization problem. n Maximizing is equivalent to minimizing n or alternatively

37 Image Segmentation Formulate as min cut problem. n G' = (V', E'). n Add source to correspond to foreground; add sink to correspond to background n Use two anti-parallel edges instead of undirected edge. st p ij ij ajaj G' bibi

38 Image Segmentation Consider min cut (A, B) in G'. n A = foreground. n Precisely the quantity we want to minimize. G' st ij A if i and j on different sides, p ij counted exactly once p ij bibi ajaj

7.11 Project Selection

40 Project Selection Projects with prerequisites. n 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 n Set of prerequisites E. If (v, w)  E, can't do project v and unless also do project w. n 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. can be positive or negative

41 Project Selection: Prerequisite Graph Prerequisite graph. n Include an edge from v to w if can't do v without also doing w. n {v, w, x} is feasible subset of projects. n {v, x} is infeasible subset of projects. n Easy to find feasible set, but what about max revenue? v w x v w x feasibleinfeasible

42 Min cut formulation. n Assign capacity  to all prerequisite edge. n Add edge (s, v) with capacity -p v if p v > 0. n Add edge (v, t) with capacity -p v if p v < 0. n For notational convenience, define p s = p t = 0. st -p w u v w x yz Project Selection: Min Cut Formulation  pvpv -p x      pypy pupu -p z 

43 Claim. (A, B) is min cut iff A  { s } is optimal set of projects. n Infinite capacity edges ensure A  { s } is feasible. n Max revenue because: s t -p w u v w x yz Project Selection: Min Cut Formulation pvpv -p x pypy pupu    A + and – all nodes in A that have positive p

44 Open-pit mining. (studied since early 1960s) n Blocks of earth are extracted from surface to retrieve ore. n Each block v has net value p v = value of ore - processing cost. n Can't remove block v before w or x. Project selection application#1: Open Pit Mining v xw

7.12 Baseball Elimination

46 Baseball Elimination Which teams have a chance of finishing the season with most wins? n Montreal eliminated since it can finish with at most 80 wins, but Atlanta already has 83. n w i + r i < w j  team i eliminated. n Only reason sports writers appear to be aware of. n Sufficient, but not necessary! Team i Against = r ij Wins w i To play r i Losses l i AtlPhiNYMon Montreal New York Philly Atlanta

47 Baseball Elimination Which teams have a chance of finishing the season with most wins? n Philly can win 83, but still eliminated... n If Atlanta loses a game, then some other team wins one. Remark. Answer depends not just on how many games already won and left to play, but also on whom they're against. Team i Against = r ij Wins w i To play r i Losses l i AtlPhiNYMon Montreal New York Philly Atlanta

48 Baseball Elimination Baseball elimination problem. n Set of teams S. n Distinguished team s  S. n Team x has won w x games already. n Teams x and y play each other r xy additional times. n Is there any outcome of the remaining games in which team s finishes with the most (or tied for the most) wins?

49 Can team 3 finish with most wins? n Assume team 3 wins all remaining games  w 3 + r 3 wins. n Find a solution of remaining games so that all teams have  w 3 + r 3 wins. Baseball Elimination: Max Flow Formulation s t r 24 = 7  w 3 + r 3 - w 4 team 4 can still win this many more games games left  game nodes team nodes

50 Theorem. Team 3 is not eliminated iff max flow saturates all edges leaving source s. n Integrality theorem  each remaining game between x and y added to number of wins for team x or team y. n Capacity on (x, t) edges ensure no team wins too many games. Baseball Elimination: Max Flow Formulation s t  team 4 can still win this many more games games left  game nodes team nodes r 24 = 7 w 3 + r 3 - w 4