Chapter 26 Maximum Flow How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin.

Slides:



Advertisements
Similar presentations
Maximum flow Main goals of the lecture:
Advertisements

COMP 482: Design and Analysis of Algorithms
1 EE5900 Advanced Embedded System For Smart Infrastructure Static Scheduling.
Max Flow: Shortest Augmenting Path
Introduction To Algorithms CS 445 Discussion Session 8 Instructor: Dr Alon Efrat TA : Pooja Vaswani 04/04/2005.
MAXIMUM FLOW Max-Flow Min-Cut Theorem (Ford Fukerson’s Algorithm)
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2012 Lecture 19.
CSCI 256 Data Structures and Algorithm Analysis Lecture 18 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.
The Maximum Network Flow Problem. CSE Network Flows.
1 Maximum Flow w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Advanced Algorithm Design and Analysis (Lecture 8) SW5 fall 2004 Simonas Šaltenis E1-215b
Chapter 26 of CLSR Maximum Network Flow by me Dr. M. Sakalli Ch26 of CSLR and many other sources. Marmara Univ. Picture taken from without permission.
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
1 The Max Flow Problem. 2 Flow networks Flow networks are the problem instances of the max flow problem. A flow network is given by 1) a directed graph.
Advanced Algorithms Piyush Kumar (Lecture 2: Max Flows) Welcome to COT5405 Slides based on Kevin Wayne’s slides.
CS138A Network Flows Peter Schröder. CS138A Flow Networks Definitions a flow network G=(V,E) is a directed graph in which each edge (u,v)
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Lecture 4 Tuesday, 2/19/02 Graph Algorithms: Part 2 Network.
1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.
1 Maximum Flow Maximum Flow Problem The Ford-Fulkerson method Maximum bipartite matching.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 4 Tuesday, 10/2/01 Graph Algorithms: Part 2 Network.
The max flow problem
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Flows sourcesink s t Flows sourcesink edge-weights = capacities.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Greed: Shortest Path s 3 t
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2004 Lecture 5 Wednesday, 10/6/04 Graph Algorithms: Part 2.
Maximum Flow Maximum Flow Problem The Ford-Fulkerson method
Graph Theory Chapter 6 from Johnsonbaugh Article(6.1, 6.2)
Maximum Flow Chapter 26.
Yangjun Chen 1 Network Flow What is a network? Flow network and flows Ford-Fulkerson method - Residual networks - Augmenting paths - Cuts of flow networks.
Single Source Shortest-Path: The General Case (with negative edges) Bellman-Ford algorithm. Iteratively relax all edges |V|-1 times Running time? O(VE).
1 COMMONWEALTH OF AUSTRALIA Copyright Regulations 1969 WARNING This material has been reproduced and communicated to you by or on behalf.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Finding Max Flow.
Max Flow – Min Cut Problem. Directed Graph Applications Shortest Path Problem (Shortest path from one point to another) Max Flow problems (Maximum material.
CS 473Lecture ?1 CS473-Algorithms I Lecture ? Network Flows Flow Networks & Flows.
Maximum Flow Chapter 26. Flow Concepts Source vertex s – where material is produced Sink vertex t – where material is consumed For all other vertices.
Chapter 7 April 28 Network Flow.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 25.
Shortest Path Algorithm 2 Prof. Sin-Min Lee Department of Computer Science.
Taken from Kevin Wayne’s slides (Princeton University) COSC 3101A - Design and Analysis of Algorithms 13 Maximum Flow.
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.
Algorithm Design and Analysis (ADA)
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.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23.
CSCE 3110 Data Structures & Algorithm Analysis Graphs (I) Reading: Chap.9, Weiss.
1 Network Flow CSC401 – Analysis of Algorithms Chapter 8 Network Flow Objectives: Flow networks –Flow –Cut Maximum flow –Augmenting path –Maximum flow.
Fall 2003Maximum Flow1 w s v u t z 3/33/3 1/91/9 1/11/1 3/33/3 4/74/7 4/64/6 3/53/5 1/11/1 3/53/5 2/22/2 
Theory of Computing Lecture 12 MAS 714 Hartmut Klauck.
Iterative Improvement for Domain-Specific Problems Lecturer: Jing Liu Homepage:
1 Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Maximum Flow Problem Definitions and notations The Ford-Fulkerson method.
The Maximum Network Flow Problem
TU/e Algorithms (2IL15) – Lecture 8 1 MAXIMUM FLOW (part II)
Maximum Flow Chapter 26.
Maximum Flow Chapter 26.
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
CS4234 Optimiz(s)ation Algorithms
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.
Edmunds-Karp Algorithm: Choosing Good Augmenting Paths
Max Flow – Min Cut Problem
COMP 382: Reasoning about Algorithms
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
Flow Networks and Bipartite Matching
Algorithms (2IL15) – Lecture 7
Chapter 7 Network Flow Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
EE5900 Advanced Embedded System For Smart Infrastructure
Presentation transcript:

Chapter 26 Maximum Flow How do we transport the maximum amount data from source to sink? Some of these slides are adapted from Lecture Notes of Kevin Wayne.

Contents Contents. Maximum flow problem. Minimum cut problem. Max-flow min-cut theorem. Augmenting path algorithm. Capacity-scaling. Shortest augmenting path.

Networks communication Network telephone exchanges, computers, satellites Nodes Arcs cables, fiber optics, microwave relays Flow voice, video, packets circuits gates, registers, processors wires current mechanical joints rods, beams, springs heat, energy hydraulic reservoirs, pumping stations, lakes pipelines fluid, oil financial stocks, currency transactions money transportation airports, rail yards, street intersections highways, railbeds, airway routes freight, vehicles, passengers chemical sites bonds energy biological genes pathways interactions

Maximum Flow & Minimum Cut Max flow and min cut. Two very rich algorithmic problems. Cornerstone problem in combinatorial optimization. Beautiful mathematical duality. Nontrivial applications / reductions. Network connectivity. Bipartite matching. Data mining. Image processing. Airline scheduling. Project selection. Network reliability. Security of statistical data. Distributed computing. Egalitarian stable matching. Computational biology. Many many more . . .

Flow Network Flow network: G = (V, E, s, t, c). (V, E) = weighted directed graph. Two distinguished vertices (nodes): s=source, t=sink. c(u,v) = capacity of edge (arc) e=(u,v). Capacity s 2 3 4 5 6 7 t 15 30 10 8 9

Positive Flows A positive s-t flow is a func. p: V ´ V ® R that satisfies: For all u, v Î V: 0  p(u,v)  c(u,v) (capacity constrain) For all u  V–{s, t}: (flow conservation) (flows out) (flows in) s 2 3 4 5 6 7 t 15 30 10 8 9 Capacity Flow * flow: entity generated at source, transmitted across edges, absorbed at sink * flow conservation is analogous to Kirchoff's law

Positive Flows A positive s-t flow is a func. p: V ´ V ® R that satisfies: For all u, v Î V: 0  p(u,v)  c(u,v) (capacity constrain) For all u  V–{s, t}: (flow conservation) (flows out) (flows in) MAX FLOW: positive s-t flow that maximizes net flow out of the source. Value = 4 Capacity s 2 3 4 5 6 7 t 15 30 10 8 9 Flow * flow conservation is analogous to Kirchoff's law

Positive Flows A positive s-t flow is a func. p: V ´ V ® R that satisfies: For all u, v Î V: 0  p(u,v)  c(u,v) (capacity constrain) For all u  V–{s, t}: (flow conservation) (flows out) (flows in) MAX FLOW: find positive s-t flow that maximizes net flow out of the source. s 2 3 4 5 6 7 t 15 30 10 8 9 11 1 Value = 24 Capacity Flow

Positive Flows A positive s-t flow is a func. p: V ´ V ® R that satisfies: For all u, v Î V: 0  p(u,v)  c(u,v) (capacity constrain) For all u  V–{s, t}: (flow conservation) (flows out) (flows in) MAX FLOW: positive s-t flow that maximizes net flow out of the source. s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Value = 28 Capacity Flow * flow conservation is analogous to Kirchoff's law

Maximum flow problem Maximize the flow over a flow network. Capacity s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Value = 28 Capacity Flow

Problem formulation

Net flow Net flow Graph G=(V,E) – a flow network Directed, each edge has capacity c(u,v) ³ 0 Two special vertices: source s, and sink t For any other vertex v, there is a path s®…®v®…®t A (net) s-t flow is a func. f : V ´ V ® R that satisfies Capacity constraint: For all u, v Î V: f(u,v) £ c(u,v) Skew symmetry: For all u, v Î V: f(u,v) = – f(v,u) Flow conservation: For all u Î V – {s, t}:

Cancellation of flows Do we want to have flows going in both directions between two vertices? No! such flows cancel (maybe partially) each other Skew symmetry – notational convenience 13 11 5 4 15 10 14 19 3 s t 9 a b c d 6 13 11 5 4 15 10 14 19 3 s t 9 a b c d 2 6

Equivalence of Definitions Define net flow in terms of positive flows f(u, v) = p(u, v) - p(v, u) How do we know f defined this way is a net flow? Capacity constrain Flow conservation Skew symmetry

Equivalence of Definitions Define positive flow in terms of net flow p(u, v) = f(u, v) if f(v, u) >0 = 0 o.w. How do we know p defined this way is a positive flow? Capacity constrain Flow conservation In literature, 2 views of flow are used. The current version (3rd edition) of our book uses positive flow.

Flow conservation Define positive flow in terms of net flow p(u, v) = f(u, v) if f(v, u) >0 = 0 o.w.

Implicit Summation Notation Function over sets  summation: Flow conservation for positive flow: Flow conservation for net flow:

Flow Conservation Theorem proof: ? s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Value = 28 Capacity Flow 28 28

Lemma G = (V,E) is a flow network. f is a net flow in G. f (X,X) = 0,  X, Y  V f (X,Y) = − f (Y,X),  X, Y  V f (XY, Z) = f (X,Z)+ f (Y,Z),  X,Y,ZV & XY= f (Z, XY) = f (Z,X)+ f (Z,Y),  X,Y,ZV & XY= Proof: …

Flow Conservation Theorem proof: Flow conservation

Cuts An s-t cut is a node partition (S, T) s.t. s  S, t  T. The capacity of an s-t cut (S, T) is: Min s-t cut: find an s-t cut of minimum capacity. s 2 3 4 5 6 7 t 15 30 10 8 9 Capacity = 30

Cuts An s-t cut is a node partition (S, T) s.t. s  S, t  T. The capacity of an s-t cut (S, T) is: Min s-t cut: find an s-t cut of minimum capacity. s 2 3 4 5 6 7 t 15 30 10 8 9 Capacity = 62

Cuts An s-t cut is a node partition (S, T) s.t. s  S, t  T. The capacity of an s-t cut (S, T) is: Min s-t cut: find an s-t cut of minimum capacity. s 2 3 4 5 6 7 t 15 30 10 8 9 Capacity = 28

Recall the example Capacity Value = 28 Flow 1 14 s 2 3 4 5 6 7 t 9 10 15 30 10 8 9 14 1 Value = 28 Capacity Flow

Flows and Cuts Lemma 1. Let f be a net flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. s 2 3 4 5 6 7 t 15 30 10 8 9 total amount of flow that leaves S minus amount flow that "swirls" back Value = 24

Flows and Cuts Lemma 1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. 10 6 4 8 s 2 3 5 7 t 15 30 9 Value = 24

Flows and Cuts Lemma 1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. 10 6 4 8 s 2 3 5 7 t 15 30 9 Value = 24

Proof of the Lemma 1 For any flow f , the flow across any cut (S, T) is the flow value | f |, i.e. f (S, T) = | f | = f (s, V). Proof: f (S, T) = f (S, V−S) = f (S, V) – f (S, S) = f (s, V) + f (S-s, V) = | f |. (lemma 1) (flow conservation)

Proof by Math Induction For any flow f , the flow across any cut (S, T) is the flow value | f |, i.e. f (S, T) = | f | = f (s,V). Proof: by induction on |S|. Base case: S = { s } . Inductive hypothesis: assume true for |S| < k. consider cut (S, T) with |S| = k S = S'  { v } for some v  s, t, |S' | = k-1  f(S', T') = | f |. adding v to S' , change to the |f| ? s v t After S' Before S skip

Flows and Cuts Lemma 2. f is a flow & (S, T) is a cut. Then |f| c(S, T). Proof. Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = c(S, T), then f is a max flow and (S, T) is a min cut. s t S T 7 6 8 4

Max Flow and Min Cut Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = c(S, T), then f is a max flow and (S, T) is a min cut. s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Cut capacity = 62 Flow value = 28

Max Flow and Min Cut Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = c(S, T), then f is a max flow and (S, T) is a min cut. s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Cut capacity = 28 Flow value = 28

Summary Lemma 1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. Lemma 2. f is a flow & (S, T) is a cut. Then |f| c(S, T). Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = c(S, T), then f is a max flow and (S, T) is a min cut.

Contents Maximum flow problem. Minimum cut problem. Max-flow min-cut theorem. Augmenting path algorithm. Capacity-scaling. Shortest augmenting path.

Max-Flow Min-Cut Theorem MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): In any network, the value of the max flow is equal to the value of the min cut. Proof: ? Flow value = 28 s 2 3 4 5 6 7 t 15 30 10 8 9 14 1 Cut capacity = 28 Later after the algorithm

Towards an Algorithm Find an s-t path where each edge e=(u,v) has c(e) > f(e) and "augment" flow along the path. Flow value = 0 s 4 2 5 3 t 10 13

Towards an Algorithm The design of this algorithm? A Greedy Algorithm Find an s-t path where each arc e=(u,v) has c(e) > f(e) and "augment" flow along the path. Repeat until you get stuck. 4 5 4 4 4 4 10 s 10 2 13 3 10 t The design of this algorithm? A Greedy Algorithm Flow value = 10

Towards an Algorithm Find an s-t path where each arc has u(e) > f(e) and "augment" flow along the path. Repeat until you get stuck. The straight forward greedy algorithm fails. s 4 2 5 3 t 10 13 Flow value = 10 Flow value = 14 s 4 2 5 3 t 10 13 6

Residual Network Let f be a flow on G = (V, E). The residual network Gf = (V, Ef ) is the graph with strictly positive residual capacities: cf (u,v) = c(u,v)−f (u,v) > 0, (where f (u,v) >0) Ef = {(u,v)VV| cf (u,v)>0}. Gf contains edges of G that can admit more net flow. (Gf GGT, where GT has G’s edges in reverse.) s 2 3 5 6 t 13 16 14 9 12 4 20 7 11 15 8 1 10 flow network and flow f residual network s 2 3 5 6 t 11 4 15 12 8 1 7 9

Residual Arcs Original graph G = (V, E). Flow f(u,v). Arc e = (u, v)  E. Residual graph: Gf = (V, Ef ). Residual arcs e = (u, v) and eR = (v, u). "Undo" flow sent. u v 17 6 Capacity Flow u v 11 Residual capacity 6

Residual Graph & Augmenting Paths Residual graph: Gf = (V, Ef ). s 4 2 5 3 t 10 13 G 10 s 4 2 5 3 t 10 Gf

Augmenting Path Augmenting path = path in residual graph. G Gf s 4 2 5 3 t 10 13 G Gf

Relation between flows on G & Gf Lemma: Let f be a flow on G=(V,E), f ’ be a flow on the residual network Gf of G. Then the flow sum (f +f ’)(u,v)  f (u,v)+f ’(u,v) is a flow on G and |f +f ’|=|f |+|f ’|. Proof: f +f ’ is a flow on G (flow conservation, capacity constrain, skew symmetry) |f +f ’| = |f |+|f ’|

Augmenting Path Augmenting path = path in residual graph. Max flow  no augmenting paths ??? s 4 2 5 3 t 10 13 G Gf Flow value = 14

Max-Flow Min-Cut Theorem Augmenting path theorem (Ford-Fulkerson, 1956): A flow f is a max flow if and only if there are no augmenting paths. MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): the value of the max flow is equal to the value of the min cut. We prove both theorems simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = c(S, T).

Proof We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = c(S, T). (i)  (ii) Let f be a flow. If there exists an augmenting path, then we can improve f by sending flow along path. (proof by contradiction) (iii)  (i) This was the Corollary to Lemma 2.

Proof (ii)  (iii) Let f be a flow with no augmenting paths. Let S be set of vertices reachable from s in residual graph. Let T=V−S. Is t  T. ? (clearly s  S, and t  S by definition of f , o.w.  augmenting path) For each u  S, v  T, f (u,v) = c(u,v). ? (o.w. cf (u,v)=c(u,v)−f (u,v)>0, then v  S). Therefore: ? |f | = f (S,T) = c(S,T). Residual Network s t S T

Ford-Fulkerson algorithm Let G=(V, E) be a flow network. Ford-Fulkerson(G,s,t,c) 01 for each edge (u,v) in E do 02 f(u,v) ¬ f(v,u) ¬ 0 03 while there exists a path p from s to t in residual network Gf do 04 cf = min{cf(u,v): (u,v) is in p} 05 for each edge (u,v) in p do 06 f(u,v) ¬ f(u,v) + cf 07 f(v,u) ¬ -f(u,v) 08 return f Cost? (E) (V+E) depth first search or breadth first search Find path --- depth first search/breath first search (V+E) (E) ( ? )

Performance If capacities are integers, O(|E|f *), f * is max flow found by the algorithm (not a polynomial algorithm). Example: 4 100 100 s 1 t 100 100 2

Performance Original network and flow Residual network 1 100 100 1 1 4 1 100 100 1 s 1 t 1 100 100 2 1 99 s 4 2 t 100 Original network and flow Residual network

Performance Maximum flow: 200 Net flow: 2. 200 iterations possible. 1 4 1 Net flow: 2. 100 100 s 1 t 100 100 2 200 iterations possible. Maximum flow: 200

Performance For noninteger capacities, might never terminate. Need more efficient algorithm (Edmonds-Karp, 1972): Augment along breadth-first augmenting path in Gf (shortest path) Augment along max-capacity augmenting path in Gf (capacity-scaling)

BFS for Shortest Paths Data structure for BFS? S S S 2 1 3 Discovered Finished Discovered Undiscovered Data structure for BFS?

Edmonds-Karp Algorithm 100 s 4 2 t 1 100 100 Takes only two iterations.

Shortest Augmenting Path Intuition: choosing path via breadth first search. Easy to implement. may implement by coincidence! Finds augmenting path with fewest number of arcs. FOREACH e  E f(e)  0 Gf  residual graph WHILE (there exists augmenting path) //find such a path P by BFS f  augment(f, P) update Gf RETURN f ShortestAugmentingPath(V, E, s, t) Cost?

Shortest Augmenting Path: Overview of Analysis Lemma1. Throughout the algorithm, the length of the shortest path increases. Proof ahead. Lemma2. After at most |E| shortest path augmentations, the length of the shortest augmenting path increases at least by one. Theorem. The shortest augmenting path algorithm runs in O(|V||E|2) time. O(|V|+|E|) time to find a shortest augmenting path via BFS. O(|E| + |E||V|) augmenting paths. (lemma 2) (If there is an augmenting path, it must be a simple one.) O(|V||E|) augmentations. O((|V|+|E|)*(|V||E|)) = O(|V||E|2) running time.

Shortest Augmenting Path: Analysis Level graph of (V, E, s). For each vertex v, define (v) to be the length (number of edges) of shortest path from s to v. LG = (V, EG) is subgraph of G that contains only those edges (v, w)  E with (w) = (v) + 1. s 2 3 5 6 t G: s 2 3 5 6 t  = 0  = 1  = 2  = 3 LG:

Shortest Augmenting Path: Analysis Level graph of (V, E, s). For each vertex v, define (v) to be the length of shortest path from s to v. L = LG = (V, F) is subgraph of G that contains only those edges (v,w)  E with (w) = (v) + 1. Compute in O(|V|+|E|) time using BFS, deleting back and side edges. P is a shortest s-v path in G if and only if it is an s-v path in L. 2 5 L: s 3 6 t  = 0  = 1  = 2  = 3

Shortest Augmenting Path: Analysis Lemma1. the length of the shortest path increases. Let f and f' be flow before and after a shortest path augmentation. Let L and L' be level graphs of residual network Gf and Gf ' Only back edges added to Gf ' path with back edge has length greater than previous length 2 5 L s 3 6 t  = 0  = 1  = 2  = 3 s 2 3 5 6 t L'

Shortest Augmenting Path: Analysis Lemma2. After at most |E| shortest path augmentations, the length of the shortest augmenting path strictly increases. At least one edge (the bottleneck edge) is deleted from L after each augmentation. No new edges added to L until length of shortest path to t strictly increases. 2 5 L Length=3 s 3 6 t Shortest path (length the same). Each one path must have at least one different edge  at most |E| shortest path  = 0  = 1  = 2  = 3 2 5 L' Length=3 s 3 6 t

Shortest Augmenting Path: Review of Analysis Theorem. The shortest augmenting path algorithm runs in O(|V||E|2) time. O(|V|+|E|) time to find a shortest augmenting path via BFS. O(|V||E|) augmentations. O((|V|+|E|)*(|V||E|)) = O(|V||E|2) running time. More rigorous proof is given in our textbook. Other approaches: Augment along max-capacity augmenting path in Gf (capacity-scaling)

Capacity Scaling Intuition: choosing path with highest bottleneck capacity increases flow by max possible amount. In practice, don't worry about finding exact highest bottleneck path. Maintain scaling parameter . Let Gf () be the subgraph of the residual graph consisting of only arcs with capacity at least . 110 s 4 2 t 1 170 102 122 Gf Gf (100)

ScalingMaxFlow(V, E, s, t) Capacity Scaling Assumption: all capacities are integers between 0 & U. FOREACH e  E, f(e)  0 (smallest power of 2 greater than or equal to U)/2 WHILE (  1) Gf()  -residual graph WHILE (there exists augmenting path P in Gf()) f  augment(f, P) update Gf()    / 2 RETURN f ScalingMaxFlow(V, E, s, t) Theorem. The algorithm runs in O(|E|2 log (2U) ) time.

Capacity Scaling: Analysis L1. If all edges capacities are integers, then throughout the algorithm, all flow and residual capacity values remain integers. Thus,  = 1  Gf() = Gf , so upon termination f is a max flow. L2. The outer while loop repeats 1 + log2 U times. Initially U/2   < U, and  decreases by a factor of 2 each iteration. L3. Let f be the flow at the end of a -scaling phase. Then value of the maximum flow is at most | f |+| E |. (proof ahead) L4. There are at most 2|E| augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. L3  |f*|  | f | + |E| (2). Each augmentation in a -phase increases | f | by at least . Theorem. The algorithm runs in O(|E|2 log (2U) ) time.

Capacity Scaling: Analysis L3. Let f be the flow at the end of a -scaling phase. Then value of the maximum flow is at most |f| + |E| . We show that at the end of a -phase, there exists a cut (S, T) such that c(S, T)  | f | + |E| . Choose S to be the set of nodes reachable from s in Gf(). clearly s  S, and t  S by definition of S S T t intuition: f is max flow in Gf(). Adding back arc with capacity less than  can only increase capacity of cut by at most m. s Original Network

Choosing Good Augmenting Paths: Summary Method Augmentations Augmenting path |V|U Max capacity |E| log U Capacity scaling Shortest path |E||V| Running time |E||V|U |E| log U (|E| + |V| log |V|) |E|2 log U |E|2|V| Improved shortest path |E||V|2 Improved capacity scaling |E||V| log U First 4 rules assume edge capacities are between 0 and U.

|E|3/2 log (|V|2 / |E|) log U |E||V|2/3 log (|V|2 / |E|) log U History Year Discoverer Method Big-Oh 1951 Dantzig Simplex |E||V|2U 1955 Ford, Fulkerson Augmenting path |E||V|U 1970 Edmonds-Karp Shortest path |E|2|V| 1970 Dinitz Shortest path |E||V|2 1972 Edmonds-Karp, Dinitz Capacity scaling |E|2 log U 1973 Dinitz-Gabow Capacity scaling |E||V| log U 1974 Karzanov Preflow-push |V|3 1983 Sleator-Tarjan Dynamic trees |E||V| log |V| M=|E|, n=|V| 1986 Goldberg-Tarjan FIFO preflow-push |E||V| log (|V|2 / |E|) . . . . . . . . . . . . 1997 Goldberg-Rao Length function |E|3/2 log (|V|2 / |E|) log U |E||V|2/3 log (|V|2 / |E|) log U

Network with multiple sources and sinks 15 14 19 30 s1 t1 a b c d 11 1 9 13 s2 t2 e f 5 4 12 23 s3 t3 g h k t s   Can be reduced to a single source & single sink max problem

Maximum bipartite matching Bipartite graph G=(V,E): Undirected V = V1V2, V1V2=. e=(u, v)E, uV1 and vV2 Complete bipartite: u V1, u is joined with every v V2 Matching: set of edges with no vertex included twice Maximum matching: a matching of maximum cardinality i.e. no matching contains more edges

Applications Dating assignment Job placement L – women, R – men. An edge between vertices: they have a chance to be “compatible” (can be matched) Job placement Companies make job offers Students have job choices An edge between vertices: the student can fit the job

Example Problem: Given N men and M women, find a matching between men and women. Participants list members of opposite sex they like to date. Zeus Amy Diane Yancey Clare Xavier Erika Wyatt Bertha Victor Diana Man 1st 2nd 3rd Men’s Preference List Can we find a perfect match? What is the max match?

Students Preference List Example Problem: Job placement Eliza IBM Google Sun Dave Apple Dell Carol HP Bob Alice Student 1st 2nd 3rd Students Preference List Frank Can we find a perfect match? What is the max match?

Maximum bipartite matching How can we reformulate this problem to become a max-flow problem?

Maximum bipartite matching How can we reformulate this problem to become a max-flow problem? Keep all edges & vertices Add source connected to all vertices in one set Add sink connected to all vertices in another set Set all capacities to 1 Theorem: The set of edges in the maxflow solution gives the solution to the maximum matching problem. Proof homework

Matching 1 Eliza Sun Dave Apple Carol IBM Bob Dell Alice HP Student F A I D H S G t s Eliza Sun Dave Apple Carol IBM Bob Dell Alice HP Student 1st 2nd 3rd Solution Frank Google

Lemma Lemma 1: Let G=(V,E), V = V1V2, V1V2=. Let G’=(V’,E’), V’ = V{s,t}, E’=…. flow network Then: If M is a matching, then there is an integer valued flow f on G’ with |f|=|M|. If f is an integer valued flow on G’, then there is a matching M on G with cardinality |M|=|f| Proof: M →f, s.t.|f|=|M| If (u,v)M, define: f(s,u)=f(u,v)=f(v,t)=1; f(u,s)=f(v,u)=f(t,v)=-1; (u,v)M, f(u,v)=0, then f is a flow and |f|=|M| ? f →M, s.t.|M|=|f| since f is an integer valued flow, f(u,v)=1 or 0. |M|=f(V1’, V2’) = |f| (skew symmetry, capacity constraints, flow conservation)

Integrality Theorem Integrality Theorem: If the capacity of a flow network is an integer function, maximum flow f produced by Ford-Fulkerson method is an integer-valued flow. Proof: homework Corollary: If |M| is the cardinality of a maximum matching M, then the value of a maximum flow f = |M|. Proof: ? Show contrapositive. suppose M is a max matching and f is not a max flow, i.e. f ’,s.t.|f ’|>|f| Then M’, s.t.|M’|=|f ’|>|f|=|M| Contradicting our assumption that M is a maximum matching.