CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

Similar documents
Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

1 Motivation and Basic Definitions

Graphs III - Network Flow

Network Flows: Introduction & Maximum Flow

Main Reference: Sections in CLRS.

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

Randomized Perfect Bipartite Matching

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

Soviet Rail Network, 1955

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Maximum Flow and Minimum Cut

18 Extensions of Maximum Flow

Algorithmic Discrete Mathematics 6. Exercise Sheet

Soviet Rail Network, 1955

CSE 521: Design & Analysis of Algorithms I

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005

Algorithm Design and Analysis

Network Flow. Data Structures and Algorithms Andrei Bulatov

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

Today: Max Flow Proofs

Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

Algorithm Design and Analysis

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

Matching. Slides designed by Kevin Wayne.

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

16 Max-Flow Algorithms and Applications

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

Introduction to Congestion Games

Introduction to SLE Lecture Notes

Reminder: Flow Networks

Network Flows UPCOPENCOURSEWARE number 34414

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover

, the. L and the L. x x. max. i n. It is easy to show that these two norms satisfy the following relation: x x n x = (17.3) max

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut

26.1 Flow networks. f (u,v) = 0.

23 Maximum Flows and Minimum Cuts

Network flows. The problem. c : V V! R + 0 [ f+1g. flow network G = (V, E, c), a source s and a sink t uv not in E implies c(u, v) = 0

Average Case Lower Bounds for Monotone Switching Networks

Inventory Analysis and Management. Multi-Period Stochastic Models: Optimality of (s, S) Policy for K-Convex Objective Functions

16 Max-Flow Algorithms

Notes for Lecture 17-18

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.

Today s topics. CSE 421 Algorithms. Problem Reduction Examples. Problem Reduction. Undirected Network Flow. Bipartite Matching. Problem Reductions

EECE 301 Signals & Systems Prof. Mark Fowler

Maximum Flow in Planar Graphs

Selfish Routing. Tim Roughgarden Cornell University. Includes joint work with Éva Tardos

CMPS 6610/4610 Fall Flow Networks. Carola Wenk Slides adapted from slides by Charles Leiserson

Physics 240: Worksheet 16 Name

They were originally developed for network problem [Dantzig, Ford, Fulkerson 1956]

CHAPTER 7: SECOND-ORDER CIRCUITS

Notes on cointegration of real interest rates and real exchange rates. ρ (2)

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Price of Stability and Introduction to Mechanism Design

Maximum Flow 5/6/17 21:08. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015

Lecture 26. Lucas and Stokey: Optimal Monetary and Fiscal Policy in an Economy without Capital (JME 1983) t t

6.8 Laplace Transform: General Formulas

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

18.03SC Unit 3 Practice Exam and Solutions

Graph Theory: Network Flow

ARTIFICIAL INTELLIGENCE. Markov decision processes

Finish reading Chapter 2 of Spivak, rereading earlier sections as necessary. handout and fill in some missing details!

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER

arxiv: v1 [cs.cg] 21 Mar 2013

3/3/2015. Chapter 7. Network Flow. Maximum Flow and Minimum Cut. Minimum Cut Problem

u(t) Figure 1. Open loop control system

T L. t=1. Proof of Lemma 1. Using the marginal cost accounting in Equation(4) and standard arguments. t )+Π RB. t )+K 1(Q RB

1 Review of Zero-Sum Games

Seminar 4: Hotelling 2

NECESSARY AND SUFFICIENT CONDITIONS FOR LATENT SEPARABILITY

Designing Information Devices and Systems I Spring 2019 Lecture Notes Note 17

We just finished the Erdős-Stone Theorem, and ex(n, F ) (1 1/(χ(F ) 1)) ( n

6.302 Feedback Systems Recitation : Phase-locked Loops Prof. Joel L. Dawson

Exponential Sawtooth

CHAPTER 12 DIRECT CURRENT CIRCUITS

5.2 GRAPHICAL VELOCITY ANALYSIS Polygon Method

EE202 Circuit Theory II

SMT 2014 Calculus Test Solutions February 15, 2014 = 3 5 = 15.

Laplace Transform. Inverse Laplace Transform. e st f(t)dt. (2)

Topics in Combinatorial Optimization May 11, Lecture 22

Mechtild Stoer * Frank Wagner** Abstract. fastest algorithm known. The runtime analysis is straightforward. In contrast to

The multisubset sum problem for finite abelian groups

Network Flow Applications

Math 2142 Exam 1 Review Problems. x 2 + f (0) 3! for the 3rd Taylor polynomial at x = 0. To calculate the various quantities:

Generalized Orlicz Spaces and Wasserstein Distances for Convex-Concave Scale Functions

7. NETWORK FLOW I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 11/22/17 6:11 AM

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

7.5 Bipartite Matching. Chapter 7. Network Flow. Matching. Bipartite Matching

EXERCISES FOR SECTION 1.5

April 3, The maximum flow problem. See class notes on website.

Random Walk with Anti-Correlated Steps

8. Basic RL and RC Circuits

Chapter 7: Solving Trig Equations

Transcription:

CSC 36S Noe Univeriy of Torono, Spring, 2003 Flow Algorihm The nework we will conider are direced graph, where each edge ha aociaed wih i a nonnegaive capaciy. The inuiion i ha if edge (u; v) ha capaciy c, hen hi mean ha a mo c amoun of \u" (for example waer, or elecriciy, or bi) can ow along he edge from u o v. We will alo have wo diinguihed verice and (for ource and erminu), and he goal i o compue he maximum amoun of \u" ha can be made o ow hrough he nework from o. Of coure, we alo have o obey he \ow conervaion" conrain ha for every verex v oher han or, he oal amoun of u owing ino v i equal o he oal amoun owing ou of v. Acually, inead of having he wo noion of u owing ino a verex and of u owing ou of a verex, we will allow negaive ow along an edge; if here i a ow of x on he edge (u; v), hen here will be a ow of x on he edge (v; u). The ow conervaion conrain hen become he aemen ha he oal amoun owing ou of verex v (oher han or ) i exacly 0; hi i equivalen o aying ha he oal amoun owing ino v i exacly 0. We now ae all hi formally. A Flow nework F = (G; c; ; ) coni of: a direced graph G = (V; E); acually, G i bidireced, ha i, if (u; v) 2 E hen (v; u) 2 E; we alo aume here are no elf loop; a nonnegaive capaciy funcion c : E! R 0 ; wo diinguihed verice: (he ource) and (he erminu or arge). Noe: The erminology \ow nework" i prey andard, bu in fac i hould be called a \capaciy nework" (or perhap o be more grammaical, a \capaciaed nework") o re he fac ha we ar wih capaciie and no ow. We can aume (wihou lo of generaliy) ha for every v 2 V, here i a pah o, and we can alo aume ha for all (u; v) 2 E, eiher c(u; v) > 0 or c(v; u) > 0 (or boh). We now dene he noion of a ow in F. Noe ha unlike capaciie, ow value are allowed o be negaive. For a verex u, we ue he noaion N(u) o denoe he neighbor of u: N(u) = fv 2 V j (u; v) 2 Eg. 1

A ow in F i a funcion f : E! R aifying: capaciy conrain: f(u; v) c(u; v) for every (u; v) 2 E kew ymmery: f(u; v) = f(v; u) for every (u; v) 2 E ow conervaion: For all u 2 V oher han or, The value of a ow f i jfj = X v2n () f(; v). X v2n (u) f(u; v) = 0 Noe ha alhough we dened jfj o be he amoun owing ou of, we will ee laer ha hi i equal o he amoun owing ino. Maximum ow problem: Given a ow nework (G; c; ; ), nd a ow of maximum poible value from o. Example: The following i an example of a ow nework. Only edge wih poiive capaciie are hown; edge wih capaciy 0 are omied from he diagram. Each edge i labelled wih i capaciy. For each edge (u; v) ha i hown, he edge (v; u) i alo aumed o be preen; if he edge (v; u) i no hown, hen i ha capaciy 0. FLOW NETWORK F: 20 v 1 v 3 1 22 10 8 7 13 15 v 2 v The following how he above example of a ow nework, ogeher wih a ow. The noaion x=y on an edge (u; v) mean x i he ow (x = f(u; v)) y i he capaciy (y = c(u; v)) Only ow on edge of poiive capaciy are hown. Noe ha negaive ow on edge of 0 capaciy are no hown. For example, f(v 2 ; ) = 8, bu hi i no explicily hown on he diagram. In hi example we have: jfj = 13 + 8 = 21. 2

FLOW NETWORK F WITH A FLOW f: v 1 1/1 v 3 13/20 17/22 0 1/ /8 7/7 8/13 / v 2 15 v Reidual Nework Le F be a ow nework, f a ow. For any (u; v) 2 E, he reidual capaciy of (u; v) induced by f i c f (u; v) = c(u; v) f(u; v) 0: The reidual graph of F induced by f i G f = (V; E f ) where E f = f(u; v) 2 E j c f (u; v) > 0g: The ow f alo give rie o he reidual ow nework F f = (G; c f ; ; ). The reidual nework F f in F f i alo a ow in F. i ielf a ow nework wih capaciie c f, and any ow The nex lemma how ha if we have a ow f in a nework and a ow f 0 in he reidual nework, hen f 0 can be added o f o obain an improved ow in he original nework. Thi will be a echnique we will ue o coninuouly improve ow unil we have a maximum poible ow. Lemma 1 Le F = (G; c; ; ) be a ow nework and le f be a ow in F. Le F f be he reidual nework induced by f, and le f 0 be a ow in F f. Then he ow um dened by (f + f 0 )(u; v) = d f(u; v) + f 0 (u; v) i a ow in F wih value jf + f 0 j = jfj + jf 0 j: 3

Proof: In order o how ha f + f 0 i a ow in F, we have o check ha he capaciy conrain, kew ymmery, and ow conervaion hold. Capaciy Conrain: (f + f 0 )(u; v) = f(u; v) + f 0 (u; v) f(u; v) + c f (u; v) = f(u; v) + (c(u; v) f(u; v)) = c(u; v). Skew Symmery: (f + f 0 )(u; v) = f(u; v) + f 0 (u; v) = f(v; u) f 0 (v; u) = (f(v; u) + f 0 (v; u)) = (f + f 0 )(v; u). Flow Conervaion: Le u be a verex oher han or. Then P v2n (u) (f + f 0)(u; v) = P v2n (u) (f(u; v) + f 0(u; v)) = P v2n (u) f(u; v) + P v2n (u) f 0(u; v) = 0 + 0 = 0. P I remain o check ha jf + f 0 j = jfj + jf 0 j. We have jf + f 0 j = (f + f v2n () 0)(; v) = P P P (f(; v) + f v2n () 0(; v)) = f(; v) + f v2n () v2n () 0(; v) = jfj + jf 0 j. Augmening Pah Given a ow nework F = (G; c; ; ) and a ow f, an augmening pah i a imple pah (ha i, a pah where no verex repea) from o in he reidual graph, G f ; noe ha every edge in G f ha poiive capaciy. Equivalenly, an augmening pah i a imple pah from o in G coniing only of edge of poiive reidual capaciy. We will ue an augmening pah o creae a ow f 0 of poiive value in F f, and hen add hi o f a in he above lemma, in order o creae he ow f 0 = f + f 0 of value bigger han f. The maximum amoun of ne ow we can hip along he edge of an augmening pah i called he reidual capaciy of. We denoe i by c f (); becaue i augmening, c f () i guaraneed o be poiive. c f () = minfc f (u; v) j (u; v) i on g > 0: Lemma 2 Fix ow nework F = (G; c; ; ), ow f, augmening pah, and dene f : E! R: 8 < c f () if (u; v) i on f (u; v) = c : f () if (v; u) i on 0 oherwie Then f i a ow in F f, and jf j = c f () > 0. Proof: In order o how ha f i a ow in F f, we have o check ha he capaciy conrain, kew ymmery, and ow conervaion hold. Capaciy Conrain: If (u; v) i on, hen f (u; v) = c f () c f (u; v); hi la inequaliy hold ince by deniion,

c f () i he malle reidual capaciy of he edge of. If (u; v) i no on, hen f (u; v) 0 c f (u; v). Skew Symmery: If (u; v) i on, hen we have f (u; v) = c f (), and f (v; u) = c f (), o f (u; v) = f (v; u). If neiher (u; v) nor (v; u) i on, hen f (u; v) = f (v; u) = 0, o f (u; v) = f (v; u). Flow Conervaion: Le u be a verex oher han or. Le u r conider he cae where u i on. Say ha edge (w; u) and (u; v) are on. Then f (u; v) = c f () and f (u; w) = c f (); for every x 2 N(u) oher han v or w, we have f (u; x) = 0. So P x2n (u) f (u; x) = 0. Now conider he cae where u i no on. Then for every x 2 N(u), f (u; x) = 0. So P x2n (u) f (u; x) = 0. I remain o check ha jf j = c f (). Le (; v) be he unique edge coming ou of ha i on. Then f (; v) = c f (). For every x 2 N() oher han v, we have f (; x) = 0. So P x2n () f (; x) = c f (). Corollary 1 Fix ow nework F = (G; c; ; ), ow f, augmening pah, and le f dened a above. Le f 0 = f + f. Then f 0 i a ow in F, and jf 0 j = jfj + jf j > jfj: be Example: Coninuing he previou example, he following diagram how he reidual graph G f coniing of edge wih poiive reidual capaciy. The reidual capaciy of each edge i alo hown. An augmening pah i indicaed by. We have c f () =. THE RESIDUAL GRAPH G f WITH AUGMENTING PATH : v1 1 v3 7 8 13 5 11 3 7 5 17 v2 11 v The following diagram how he nework F wih ow f 0 = f + f. We have jf 0 j = jfj + jf j = 21 + c f () = 21 + = 25. 5

FLOW NETWORK F WITH FLOW f 0 : v 1 1/1 v 3 13/20 21/22 0 1/ 0/8 7/7 12/13 / v 2 15 v Afer creaing he improved ow f 0, i i naural o ry he ame rick again and look for an augmening pah wih repec o f 0. Tha i, we conider he new reidual graph G f 0 and look for a pah from o. We ee however, ha no uch pah exi. THE RESIDUAL GRAPH G f 0: v 1 1 v 3 7 13 1 12 11 3 8 7 1 21 v 2 11 v All of he above ugge he famou Ford-Fulkeron algorihm for nework ow. The algorihm begin by iniializing he ow f o he all-0 ow, ha i, he ow ha i 0 along every edge. The algorihm hen coninually improve f by earching for an augmening pah, and uing hi pah o improve f, a in he previou lemma. The algorihm hal when here i no longer any augmening pah. Ford-Fulkeron(G; c; ; ) Iniialize ow f o he all-0 ow WHILE here exi an augmening pah in G f chooe an augmening pah f f + f end WHILE DO 6

There are a number of obviou queion o ak abou hi algorihm. Firly, how are we uppoed o earch for augmening pah? Tha i, how do we look for a pah from o in he graph G f? There are many algorihm we could ue. However, ince all we wan o do i nd a pah beween wo poin in an unweighed, direced graph, wo of he imple and fae algorihm we can ue are \deph-r earch" or \breadh-r" earch. Each of hee algorihm run in ime linear in he ize of he graph, ha i, linear in he number of edge in he graph. The nex queion i, i he algorihm guaraneed o hal? The anwer o hi, remarkably, i NO. If we do no conrain how he algorihm earche for augmening pah, hen here are example where i can run forever. Thee example are complicaed and ue irraional capaciie, and we will no how one here. Wha if he capaciie are all ineger? Then i i clear ha he algorihm increae he ow by a lea 1 each ime hrough he loop, and o i will evenually hal. (Exercie: ll in he deail of hi argumen; give a imilar argumen in cae he capaciie are only guaraneed o be raional number.) However, hi may ill ake a very long ime. A an example, conider he following ow nework wih only verice. If we are lucky (or careful), he algorihm will chooe [; v 1 ; ] for he r augmening pah, creaing a ow wih value 1000; i will hen have no choice bu o chooe [; v 2 ; ] for he nex augmening pah, and i will be hal, having creaed a ow wih value 2000. However, he algorihm may chooe [; v 1 ; v 2 ; ] a i r augmening pah, creaing a ow wih value 1; i may hen chooe [; v 2 ; v 1 ; ] a he nex augmening pah, creaing a ow wih value 2; coninuing in hi way, i may go 2000 ime hrough he loop before i evenually hal. EXAMPLE OF A BAD FLOW NETWORK FOR FORD-FULKERSON: v1 1000 1000 1 1000 1000 v2 We will ee laer, however, ha if we conrain how Ford-Fulkeron chooe i augmening pah, hen we can ge a verion of he algorihm ha run in ime polynomial in he ize of he nework. 7

For he momen, we will concern ourelve wih one la queion abou he algorihm. Le' aume i doe hal; i i hen he cae ha he ow i ha found i a large a poible? The anwer urn ou o be YES! We know ha if an augmening pah exi hen he curren ow i no opimal. We wan o prove ha if here i no augmening pah, hen he curren ow i opimal. Thi i a very uble proof. Le u x ow nework F = (G; c; ; ), G = (V; E), and ow f. We are going o inroduce he new noion of a cu of F. We will ee ha if here i no augmening pah, hen here will exi a pecial cu ha how ha f i opimal. Cu of Flow Nework A cu (S; T ) of F i a pariion of V ino S and T = V S uch ha 2 S and 2 T. We dene he capaciy of (S; T ) o be he um of he capaciie over all edge going from S o T ; noe ha hi i a um of nonnegaive number. We dene he ow acro (S; T ) o be he um of he ow over all edge going from S o T ; noe ha hi um may coni of negaive number. More formally: The capaciy of he cu (S; T ) i dened by c(s; T ) = X (x;y)2(st )\E c(x; y) The ow acro (S; T ) i f(s; T ) = X (x;y)2(st )\E f(x; y) Noe ha we are lighly abuing noaion by exending he deniion of ow and capaciie o e of node. Example: Conider our earlier example of he ow nework F wih ow f 0. Conider he cu (S; T ) = (f; v 3 g; f; v 1 ; v 2 ; v g). We have c(s; T ) = 20 + 13 + 8 + 22 = 63 and f 0 (S; T ) = 13 + 12 + ( 1) + ( 7) + 21 = 25. We ee ha f(s; T ) in he above example i exacly equal o jfj, and hi i no coincidence. Inuiively i make ene ha he amoun owing ou of hould be exacly he ame a he amoun owing acro any cu, and hi i proven in he nex lemma. In paricular, by conidering he cu (V fg; fg), we ee ha jfj i exacly equal o he amoun owing ino. Lemma 3 Fix ow nework F = (G; c; ; ) and ow f. Then for every cu (S; T ), f(s; T ) = jfj. 8

Proof: Le (S; T ) be a cu. Conider he following ve e of edge: E 1 = (S T ) \ E; E 2 = (S V ) \ E; E 3 = (S S) \ E; E = (fg V ) \ E; E 5 = ((S fg) V ) \ E; Fir, we claim ha P e2e 3 f(e) = 0. Thi i becaue for every edge (u; v) in E 3, (v; u) i alo in E 3, and by kew ymmery we have f(u; v) + f(v; u)=0. P We nex claim ha e2e 5 f(e) = 0. Thi i becaue ow conervaion for every node u oher Phan or allow P u o Pwrie P e2e 5 f(e) = f(u; v) = 0 = 0. u2s fg v2n (u) u2s fg PSince E 2 i he P dijoin union P of E 1 and E P 3, we have e2e 2 f(e) = e2e 1 f(e) + e2e 3 f(e) = e2e 1 f(e). PSince E 2 i he P dijoin union P of E and E P 5, we have e2e 2 f(e) = e2e f(e) + e2e 5 f(e) = e2e f(e). Puing all hi ogeher, we have f(s; T ) = P e2e 1 f(e) = P e2e 2 f(e) = P e2e f(e) = jfj. Lemma Fix ow nework F = (G; c; ; ) and ow f. Then for every cu (S; T ), f(s; T ) c(s; T ). Proof: f(s; T ) = P e2(st )\E f(e) P e2(st )\E c(e) = c(s; T ). Corollary 2 The value of every ow in F i le han or equal o he capaciy of every cu of F. We now ae and prove he famou \max-ow, min cu" heorem. Thi heorem ay ha he maximum value over all ow in F i exacly equal o he minimum capaciy over all cu. I alo ell u ha if F ha no augmening pah wih repec o a ow f, hen jfj i he maximum poible. Theorem 1 (MAX-FLOW, MIN-CUT THEOREM) Fix ow nework F = (G; c; ; ), G = (V; E), and ow f. Then he following are equivalen 1. f i a max ow (ha i, a ow of maximum poible value) in F. 2. There are no augmening pah wih repec o f. 3. jfj = c(s; T ) for ome cu (S; T ) of F. 9

Proof: (1) ) (2) Suppoe (1) hold. We have already een ha if here were an augmening pah wih repec o f, hen a ow wih value larger han jfj could be conruced. Since f i a max ow, here mu be no augmening pah. (2) ) (3) Suppoe (2) hold. Then here i no pah from o in G f. Le S = fv 2 V j here exi a pah from o v in G f g, and le T = V S. Clearly (S; T ) i a cu. We claim ha jfj = c(s; T ). From he above Lemma 3, i uce o how ha f(s; T ) = c(s; T ). For hi, i uce o how ha for every edge (u; v) 2 (S T ) \ E, f(u; v) = c(u; v). So conider uch an edge (u; v). If we had f(u; v) < c(u; v), hen (u; v) would be an edge wih poiive reidual capaciy, and hence (u; v) would be an edge of G f, and hence (ince u 2 S), here would be a pah in G f from o v, and hence v 2 S { a conradicion. (3) ) (1) Suppoe (3) hold. Le (S; T ) be a cu of F uch ha jfj = c(s; T ). From he above corollary, we know ha every ow ha value le han or equal o c(s; T ), and hence every ow ha value le han or equal o jfj. So f i a max ow. Thi heorem ell u ha if Ford-Fulkeron hal, hen he reuling ow i opimal. Le u now reurn o he queion of how o modify Ford-Fulkeron o ha i i guaraneed o no only hal, bu o hal reaonably quickly. The Edmond-Karp verion of hi algorihm look for a pah in G f uing breadh-r earch. Thi nd a pah ha conain a few edge a poible. We call hi algorihm FF-EK: FF-EK(G; c; ; ) Iniialize ow f o he all-0 ow WHILE here exi an augmening pah in G f DO chooe an augmening pah uing breadh-r earch in G f f f + f end WHILE Le u aume (wihou lo of generaliy) ha jej jv j. Then breadh-r earch nd an augmening pah (if here i one) in ime O(jEj). Uing an augmening pah o improve he ow ake ime O(jEj), o each execuion of he main loop run in ime O(jEj). I i a dicul heorem (ha we will no prove here) ha he main loop of FF-EK will be execued a mo O(jV jjej) ime. Thu, FF-EK hal in ime O(jV jjej 2 ). Hence, hi i a polynomial ime algorihm. A huge amoun of reearch ha been done in hi area, and even beer algorihm have been found. One of he fae ha running ime O(jV j 3 ). 10

Example: Conider he previou example of ow nework F wih ow f 0. We know ha jf 0 j = 25, and o he ow acro every cu will be 25, and he capaciy of every cu will be greaer han or equal o 25. We have een ha here i no augmening pah, o he above heorem ell u ha here mu be a cu of capaciy 25. I even ell u how o nd uch a cu: le S be he e of node reachable from in G f 0. In fac, i i eay o check ha if we chooe S = f; v 1 ; v 2 ; v g and T = fv 3 ; g, hen c(s; T ) = 1 + 7 + = 25. An Applicaion o Finding Maximum Maching in Biparie Graph There are many applicaion of max-ow algorihm o area which appear very dieren. A an example, we hall how how o ue a max ow algorihm o nd a maximum maching in a biparie graph. A biparie graph i a direced graph G = (V; E) where V i pariioned ino wo par L and R (for lef and righ) uch ha all edge go from L o R. Tha i, V = L[R, L\R = ;, and E L R. A maching i dened o be a e of edge M E uch ha no wo (diinc) edge of M have a verex in common. The ize of M i dened o be jmj, he number of edge in M. We wih o nd a maximum maching, ha i, a maching of bigge poible ize. I urn ou ha here i a way o conver uch a maching problem ino a ow problem. Fir we add wo verice o creae V 0 = V [ f; g. We add edge from o each verex in L, and edge from each verex in R o ; all of hee edge (including he original edge in E) are aigned capaciy 1. Laly, we add he he revere of all hee edge, wih capaciy 0. In hi way we form he ow nework F = (G 0 ; c; ; ), G 0 = (V 0 ; E 0 ). Conider ineger ow in F, ha i, ow ha ake on ineger value on every edge; for each edge of capaciy 1, he ow on i mu be eiher 1 or 0 (ince i revere edge ha capaciy 0). I i eay o ee ha Ford-Fulkeron, when applied o a nework wih only ineger capaciie, will alway yield an ineger (maximum) ow. The following wo lemma how ha an ineger ow f can be ued o conruc a maching of ize jfj, and ha a maching M can be ued o conruc a ow of value jmj. Thi will allow u o ue Ford-Fulkeron o compue a maximum ow in polynomial ime. Lemma 5 Le G = (V; E) and F = (G 0 ; c; ; ) be a above, and le f be an ineger ow in F. Then here i a maching M in G uch ha jmj = jfj. Proof: Le f be an ineger ow. Le M = f(u; v) 2 L R j f(u; v) = 1:g. To ee why M i a maching, imagine ha (u; v 1 ); (u; v 2 ) 2 M for ome v 1 P 6= v 2 ; ince u ha only one edge of poiive capaciy (namely 1) coming ino i, we would have f(u; v) v2n (u) 1, conradicing ow conervaion. (A imilar argumen how ha no wo edge in M can hare a righ endpoin.) 11

We now how ha jmj = jfj. Recall ha jfj i equal o he oal ow coming ou of. So we mu have jfj diinc verice u 1 ; u 2 ; : : : ; u jf j uch ha f(; u 1 ) = 1; f(; u 2 ) = 1; : : : ; f(; u jf j ) = 1. So in order for ow conervaion o hold, for each u i we mu have ome v i 2 R uch ha f(u i ; v i ) = 1. So (u i ; v i ) 2 M for each i, and we have jmj = jfj. Lemma 6 Le G = (V; E) and F = (G 0 ; c; ; ) be a above, and le M be a maching in G. Then here exi a ow f in F wih jfj = jmj. Proof: Le M = f(u 1 ; v 1 ); (u 2 ; v 2 ); : : : ; (u jm j ; v jm j ) L Rg be a maching. Dene f by f(; u i ) = 1, f(u i ; v i ) = 1, f(v i ; ) = 1 (and f(u i ; ) = 1, f(v i ; u i ) = 1, f(; v i ) = 1) for each i, and f(e) = 0 for every oher edge e 2 E 0. I i eay o check ha f i a ow, and ha jfj = jmj (exercie). We now ee how o ue Ford-Fulkeron o nd a maximum maching in G = (V; E). Aume, wihou lo of generaliy, ha jv j jej. Noe ha jv 0 j 2 O(jV j) and je 0 j 2 O(jEj). We r conruc F = (G 0 ; c; ; ) a above; hi ake ime O(jEj). We hen perform he Ford-Fulkeron algorihm o creae a maximum ow f. We oberve ha hi algorihm, no maer how we nd augmening pah, will increae he ow value by exacly 1 each ime, and hence will execue i main loop a mo jv j ime. If we ue an O(jEj) ime algorihm o earch for augmening pah, hen each execuion of he loop will ake ime O(jEj). So he oal ime of he Ford-Fulkeron algorihm here i O(jV jjej). Laly, we ue he ineger ow f o creae a maching M in G uch ha jmj = jfj; hi ake ime O(jEj). The la lemma above ell u ha ince f i a maximum ow, M mu be a maximum maching. So he enire maximum maching algorihm run in ime O(jV jjej). Thi i a polynomial ime algorihm. Faer algorihm have alo been found. For example, here i an algorihm for hi problem ha run in ime O( p jv jjej). Example: The following i an example of a (direced) biparie graph G. The nex gure how he nework F derived from G, ogeher wih a maximum ow f in F. The la gure how he maximum maching M obained from f. 12

A BIPARTITE GRAPH G: FLOW NETWORK F DERIVED FROM G, WITH A MAXIMUM FLOW f: 0/1 0/1 0/1 0/1 A MAXIMUM MATCHING IN G DERIVED FROM FLOW f: 13