introduction Ford-Fulkerson algorithm

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

Algorithms. Algorithms 6.4 MAXIMUM FLOW

introduction Ford-Fulkerson algorithm

Soviet Rail Network, 1955

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

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

Soviet Rail Network, 1955

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

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

1 Motivation and Basic Definitions

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

Maximum Flow and Minimum Cut

Today: Max Flow Proofs

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

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

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

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

Algorithm Design and Analysis

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

Matching. Slides designed by Kevin Wayne.

Algorithms. Algorithms 6.4 MIN CUT / MAX FLOW

Algorithms. Algorithms 6.4 MAXIMUM FLOW

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

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

Main Reference: Sections in CLRS.

Algorithm Design and Analysis

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

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Graphs III - Network Flow

Algorithmic Discrete Mathematics 6. Exercise Sheet

CSE 521: Design & Analysis of Algorithms I

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

16 Max-Flow Algorithms and Applications

Algorithms 6.4 MAXIMUM FLOW. overview Ford-Fulkerson algorithm analysis Java implementation applications

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

Randomized Perfect Bipartite Matching

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.

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

Network Flows: Introduction & Maximum Flow

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

Reminder: Flow Networks

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

Network Flow. Data Structures and Algorithms Andrei Bulatov

Ford Fulkerson algorithm max-flow min-cut theorem. max-flow min-cut theorem capacity-scaling algorithm

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

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

Network Flows UPCOPENCOURSEWARE number 34414

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

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

7. NETWORK FLOW II. Soviet rail network (1950s) Max-flow and min-cut applications. "Free world" goal. Cut supplies (if cold war turns into real war).

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

18 Extensions of Maximum Flow

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

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

23 Maximum Flows and Minimum Cuts

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

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)

Maximum Flow in Planar Graphs

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

7. NETWORK FLOW II. Minimum cut application (RAND 1950s) Maximum flow application (Tolstoǐ 1930s) Max-flow and min-cut applications

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

Introduction to Congestion Games

16 Max-Flow Algorithms

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

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

20/20 20/20 0/5 0/5 20/20 20/20 5/5 0/5 0/5 5/5 0/20 25/30 20/20 30/30 20/20 0/5 5/5 20/20 0/5 0/5 15/20 15/25 20/20 10/10

EECE 301 Signals & Systems Prof. Mark Fowler

Wrap up: Weighted, directed graph shortest path Minimum Spanning Tree. Feb 25, 2019 CSCI211 - Sprenkle

Network Flow Applications

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

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

DETC2004/CIE ALGORITHMIC FOUNDATIONS FOR CONSISTENCY-CHECKING OF INTERACTION-STATES OF MECHATRONIC SYSTEMS

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER

Average Case Lower Bounds for Monotone Switching Networks

Stationary Distribution. Design and Analysis of Algorithms Andrei Bulatov

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

Introduction to SLE Lecture Notes

, 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

An introduction to the theory of SDDP algorithm

Random Walk with Anti-Correlated Steps

Selfish Routing and the Price of Anarchy. Tim Roughgarden Cornell University

Graph Theory: Network Flow

18.03SC Unit 3 Practice Exam and Solutions

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

Research Article On Double Summability of Double Conjugate Fourier Series

The Primal Simplex Approach to the QoS Routing Problem

Geometric Path Problems with Violations

arxiv: v1 [cs.cg] 21 Mar 2013

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

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

CHAPTER 7: SECOND-ORDER CIRCUITS

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

ARTIFICIAL INTELLIGENCE. Markov decision processes

Additional Methods for Solving DSGE Models

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

Macroeconomics 1. Ali Shourideh. Final Exam

Let. x y. denote a bivariate time series with zero mean.

Mon Apr 2: Laplace transform and initial value problems like we studied in Chapter 5

Price of Stability and Introduction to Mechanism Design

Transcription:

Algorihm ROBERT SEDGEWICK KEVIN WAYNE. MAXIMUM FLOW. MAXIMUM FLOW inroducion inroducion Ford-Fulkeron algorihm Ford-Fulkeron algorihm Algorihm F O U R T H E D I T I O N maxflow-mincu heorem analyi of running ime Algorihm maxflow-mincu heorem analyi of running ime ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu Java implemenaion applicaion ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu Java implemenaion applicaion Mincu problem Mincu problem Inpu. An edge-weighed digraph, ource verex, and arge verex. each edge ha a poiive capaciy Def. A -cu (cu) i a pariion of he verice ino wo dijoin e, wih in one e A and in he oher e B. Def. I capaciy i he um of he capaciie of he edge from A o B. capaciy capaciy = + + =

Mincu problem Mincu problem Def. A -cu (cu) i a pariion of he verice ino wo dijoin e, Def. A -cu (cu) i a pariion of he verice ino wo dijoin e, wih in one e A and in he oher e B. wih in one e A and in he oher e B. Def. I capaciy i he um of he capaciie of he edge from A o B. Def. I capaciy i he um of he capaciie of he edge from A o B. Minimum -cu (mincu) problem. Find a cu of minimum capaciy. don' coun edge from B o A capaciy = + + = capaciy = + + = Mincu applicaion (RAND ) Poenial mincu applicaion () "Free world" goal. Cu upplie (if cold war urn ino real war). Governmen-in-power goal. Cu off communicaion o e of people. rail nework connecing Sovie Union wih Eaern European counrie (map declaified by Penagon in ) Figure From Harri and Ro []: Schemaic diagram of he railway nework of he Weern Sovie Union and Eaern European counrie, wih a maximum flow of value, on from Ruia o Eaern Europe, and a cu of capaciy, on indicaed a The boleneck.

v Maxflow problem Maxflow problem Inpu. An edge-weighed digraph, ource verex, and arge verex. each edge ha a poiive capaciy Def. An -flow (flow) i an aignmen of value o he edge uch ha: Capaciy conrain: edge' flow edge' capaciy. Local equilibrium: inflow = ouflow a every verex (excep and ). capaciy flow capaciy / inflow a v = + + = ouflow a v = + = / / / / / / / / / / / / Maxflow problem Maxflow problem Def. An -flow (flow) i an aignmen of value o he edge uch ha: Capaciy conrain: edge' flow edge' capaciy. Local equilibrium: inflow = ouflow a every verex (excep and ). Def. The value of a flow i he inflow a. Def. An -flow (flow) i an aignmen of value o he edge uch ha: Capaciy conrain: edge' flow edge' capaciy. Local equilibrium: inflow = ouflow a every verex (excep and ). Def. The value of a flow i he inflow a. we aume no edge poin o or from Maximum -flow (maxflow) problem. Find a flow of maximum value. / / / / / / / / / / / / / value = + + = / / / value = + + = / / / / / / / / / /

Maxflow applicaion (Toloǐ ) Poenial maxflow applicaion () Sovie Union goal. Maximize flow of upplie o Eaern Europe. "Free world" goal. Maximize flow of informaion o pecified e of people. flow capaciy facebook graph rail nework connecing Sovie Union wih Eaern European counrie (map declaified by Penagon in ) Figure From Harri and Ro []: Schemaic diagram of he railway nework of he Weern Sovie Union and Eaern European counrie, wih a maximum flow of value, on from Ruia o Eaern Europe, and a cu of capaciy, on indicaed a The boleneck. Summary Inpu. A weighed digraph, ource verex, and arge verex. Mincu problem. Find a cu of minimum capaciy. Maxflow problem. Find a flow of maximum value.. M AXIMUM F LOW / / / / / / / / / / / / / / inroducion Ford-Fulkeron algorihm Algorihm / value of flow = R OBERT S EDGEWICK K EVIN W AYNE capaciy of cu = hp://alg.c.princeon.edu Remarkable fac. Thee wo problem are dual! maxflow-mincu heorem analyi of running ime Java implemenaion applicaion

Ford-Fulkeron algorihm Idea: increae flow along augmening pah Iniializaion. Sar wih flow. Augmening pah. Find an undireced pah from o uch ha: Can increae flow on forward edge (no full). Can decreae flow on backward edge (no empy). iniializaion flow capaciy augmening pah / / boleneck capaciy = / / / / value of flow / / / / / / / / / / + = / / / / / / / / / / Idea: increae flow along augmening pah Idea: increae flow along augmening pah Augmening pah. Find an undireced pah from o uch ha: Can increae flow on forward edge (no full). Can decreae flow on backward edge (no empy). Augmening pah. Find an undireced pah from o uch ha: Can increae flow on forward edge (no full). Can decreae flow on backward edge (no empy). nd augmening pah / rd augmening pah / backward edge (no empy) / / / / / / / / / / / + = / / / + = / / / / / / / / / /

Idea: increae flow along augmening pah Idea: increae flow along augmening pah Augmening pah. Find an undireced pah from o uch ha: Can increae flow on forward edge (no full). Can decreae flow on backward edge (no empy). Terminaion. All pah from o are blocked by eiher a Full forward edge. Empy backward edge. h augmening pah / backward edge (no empy) no more augmening pah / / / / / / / / / / / / + = / / / / / / / / / / / / / full forward edge empy backward edge Ford-Fulkeron algorihm Queion. How o compue a mincu? How o find an augmening pah? Ford-Fulkeron algorihm Sar wih flow. While here exi an augmening pah: - find an augmening pah - compue boleneck capaciy - increae flow on ha pah by boleneck capaciy If FF erminae, doe i alway compue a maxflow? Doe FF alway erminae? If o, afer how many augmenaion? Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu. MAXIMUM FLOW inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion

Relaionhip beween flow and cu Relaionhip beween flow and cu Def. The ne flow acro a cu (A, B) i he um of he flow on i edge from A o B minu he um of he flow on i edge from B o A. Def. The ne flow acro a cu (A, B) i he um of he flow on i edge from A o B minu he um of he flow on i edge from B o A. ne flow acro cu = + + = ne flow acro cu = + + = / / / / / / / / / / / / / value of flow = / / / value of flow = / / / / / / / / / / Relaionhip beween flow and cu Relaionhip beween flow and cu Def. The ne flow acro a cu (A, B) i he um of he flow on i edge from A o B minu he um of he flow on i edge from B o A. Flow-value lemma. Le f be any flow and le (A, B) be any cu. Then, he ne flow acro (A, B) equal he value of f. Inuiion. Conervaion of flow. ne flow acro cu = ( + + + + + ) ( + + + ) = / Pf. By inducion on he ize of B. Bae cae: B =. Inducion ep: remain rue by local equilibrium when moving any verex from A o B. edge from B o A / / / / / / / value of flow = Corollary. Ouflow from = inflow o = value of flow. / / / / /

Relaionhip beween flow and cu Maxflow-mincu heorem Weak dualiy. Le f be any flow and le (A, B) be any cu. Then, he value of he flow he capaciy of he cu. Augmening pah heorem. A flow f i a maxflow iff no augmening pah. Maxflow-mincu heorem. Value of he maxflow = capaciy of mincu. Pf. Value of flow f = ne flow acro cu (A, B) capaciy of cu (A, B). flow-value lemma flow bounded by capaciy Pf. The following hree condiion are equivalen for any flow f : i. There exi a cu whoe capaciy equal he value of he flow f. ii. f i a maxflow. iii. There i no augmening pah wih repec o f. / / / / / / / / [ i ii ] Suppoe ha (A, B) i a cu wih capaciy equal o he value of f. Then, he value of any flow f ' capaciy of (A, B) = value of f. Thu, f i a maxflow. weak dualiy by aumpion / / / / / value of flow = capaciy of cu = Maxflow-mincu heorem Maxflow-mincu heorem Augmening pah heorem. A flow f i a maxflow iff no augmening pah. Augmening pah heorem. A flow f i a maxflow iff no augmening pah. Maxflow-mincu heorem. Value of he maxflow = capaciy of mincu. Maxflow-mincu heorem. Value of he maxflow = capaciy of mincu. Pf. The following hree condiion are equivalen for any flow f : Pf. The following hree condiion are equivalen for any flow f : i. There exi a cu whoe capaciy equal he value of he flow f. i. There exi a cu whoe capaciy equal he value of he flow f. ii. f i a maxflow. ii. f i a maxflow. iii. There i no augmening pah wih repec o f. iii. There i no augmening pah wih repec o f. [ ii iii ] We prove conrapoiive: ~iii ~ii. Suppoe ha here i an augmening pah wih repec o f. Can improve flow f by ending flow along hi pah. Thu, f i no a maxflow. [ iii i ] Suppoe ha here i no augmening pah wih repec o f. Le (A, B) be a cu where A i he e of verice conneced o by an undireced pah wih no full forward or empy backward edge. By definiion of cu, i in A. Since no augmening pah, i in B. Capaciy of cu = ne flow acro cu = value of flow f. forward edge full; backward edge empy flow-value lemma

Compuing a mincu from a maxflow To compue mincu (A, B) from maxflow f : By augmening pah heorem, no augmening pah wih repec o f. Compue A = e of verice conneced o by an undireced pah wih no full forward or empy backward edge. A forward edge (no full) / / / / / / / / / / / / / / full forward edge empy backward edge Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu. MAXIMUM FLOW inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion backward edge (no empy) Ford-Fulkeron algorihm Ford-Fulkeron algorihm wih ineger capaciie Ford-Fulkeron algorihm Sar wih flow. While here exi an augmening pah: - find an augmening pah - compue boleneck capaciy - increae flow on ha pah by boleneck capaciy Imporan pecial cae. Edge capaciie are ineger beween and U. Invarian. The flow i ineger-valued hroughou Ford-Fulkeron. Pf. [by inducion] flow on each edge i an ineger Boleneck capaciy i an ineger. Flow on an edge increae/decreae by boleneck capaciy. Queion. How o compue a mincu? Eay. How o find an augmening pah? BFS work well. If FF erminae, doe i alway compue a maxflow? Ye. Doe FF alway erminae? If o, afer how many augmenaion? ye, provided edge capaciie are ineger (or augmening pah are choen carefully) require clever analyi Propoiion. Number of augmenaion he value of he maxflow. Pf. Each augmenaion increae he value by a lea. criical for ome applicaion (ay uned) Inegraliy heorem. There exi an ineger-valued maxflow. Pf. Ford-Fulkeron erminae and maxflow ha i find i ineger-valued.

Bad cae for Ford-Fulkeron Bad cae for Ford-Fulkeron Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. iniialize wih flow ieraion flow capaciy Bad cae for Ford-Fulkeron Bad cae for Ford-Fulkeron Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. nd ieraion rd ieraion

Bad cae for Ford-Fulkeron Bad cae for Ford-Fulkeron Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. h ieraion... Bad cae for Ford-Fulkeron Bad cae for Ford-Fulkeron Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. h ieraion h ieraion

Bad cae for Ford-Fulkeron How o chooe augmening pah? Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. can be exponenial in inpu ize Good new. Thi cae i eaily avoided. [ue hore/fae pah] Ue care when elecing augmening pah. Some choice lead o exponenial algorihm. Clever choice lead o polynomial algorihm. augmening pah number of pah implemenaion random pah E U randomized queue DFS pah E U ack (DFS) hore pah ½ E V queue (BFS) fae pah E ln(e U) prioriy queue digraph wih V verice, E edge, and ineger capaciie beween and U How o chooe augmening pah? Chooe augmening pah wih: Shore pah: fewe number of edge. Fae pah: max boleneck capaciy.. MAXIMUM FLOW Theoreical Improvemen in Algorihmic Efficiency for Nework Flow Problem JACK EDMONDS Univeriy of Waerloo, Waerloo, Onario, Canada AND RICHARD M. KARP Univeriy of California, Berkeley, California ABSTRACT. Thi paper preen new algorihm for he maximum flow problem, he Hichcock ranporaion problem, and he general minimum-co flow problem. Upper bound on he number of ep in hee algorihm are derived, and are hown o compale favorably wih upper bound on he number of ep required by earlier algorihm. Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion Edmond-Karp (USA) Dinic (Sovie Union)

w v Flow nework repreenaion Flow nework repreenaion Flow edge daa ype. Aociae flow fe and capaciy ce wih edge e = v w. Reidual nework. A ueful view of a flow nework. include all edge wih poiive reidual capaciy flow fe capaciy ce original nework / / / / / / / Flow nework daa ype. Mu be able o proce edge e = v w in eiher / / / direcion: include e in adjacency li of boh v and w. reidual nework backward edge (no empy) Reidual (pare) capaciy. Forward edge: reidual capaciy = ce fe. Backward edge: reidual capaciy = fe. Augmen flow. Forward edge: add. Backward edge: ubrac. reidual capaciy v forward edge w backward edge Key poin. Augmening pah in original nework are in - correpondence wih direced pah in reidual nework. forward edge (no full) Flow edge API Flow edge: Java implemenaion public cla FlowEdge FlowEdge(in v, in w, double capaciy) creae a flow edge v w in from() verex hi edge poin from in o() verex hi edge poin o in oher(in v) oher endpoin double capaciy() capaciy of hi edge double flow() flow in hi edge double reidualcapaciyto(in v) reidual capaciy oward v void addreidualflowto(in v, double dela) add dela flow oward v / w v public cla FlowEdge privae final in v, w; privae final double capaciy; privae double flow; // from and o // capaciy // flow public FlowEdge(in v, in w, double capaciy) hi.v = v; hi.w = w; hi.capaciy = capaciy; flow variable (muable) public in from() reurn v; public in o() reurn w; public double capaciy() reurn capaciy; public double flow() reurn flow; flow fe capaciy ce reidual capaciy v forward edge w backward edge public in oher(in verex) if (verex == v) reurn w; ele if (verex == w) reurn v; ele hrow new IllegalArgumenExcepion(); public double reidualcapaciyto(in verex)... public void addreidualflowto(in verex, double dela)... nex lide

w v w v Flow edge: Java implemenaion (coninued) Flow nework API public double reidualcapaciyto(in verex) if (verex == v) reurn flow; ele if (verex == w) reurn capaciy - flow; ele hrow new IllegalArgumenExcepion(); public void addreidualflowto(in verex, double dela) if (verex == v) flow -= dela; ele if (verex == w) flow += dela; ele hrow new IllegalArgumenExcepion(); forward edge backward edge forward edge backward edge public cla FlowNework FlowNework(in V) creae an empy flow nework wih V verice FlowNework(In in) conruc flow nework inpu ream void addedge(flowedge e) add flow edge e o hi flow nework Ierable<FlowEdge> adj(in v) forward and backward edge inciden o v Ierable<FlowEdge> edge() all edge in hi flow nework in V() number of verice in E() number of edge Sring osring() ring repreenaion flow fe capaciy ce reidual capaciy forward edge / backward edge Convenion. Allow elf-loop and parallel edge. Flow nework: Java implemenaion Flow nework: adjacency-li repreenaion public cla FlowNework privae final in V; privae Bag<FlowEdge>[] adj; public FlowNework(in V) hi.v = V; adj = (Bag<FlowEdge>[]) new Bag[V]; for (in v = ; v < V; v++) adj[v] = new Bag<FlowEdge>(); public void addedge(flowedge e) in v = e.from(); in w = e.o(); adj[v].add(e); adj[w].add(e); ame a EdgeWeighedGraph, bu adjacency li of FlowEdge inead of Edge add forward edge add backward edge Mainain verex-indexed array of FlowEdge li (ue Bag abracion). inyfn.x V E........ adj[]........ reference o he ame FlowEdge objec........................ Bag objec public Ierable<FlowEdge> adj(in v) reurn adj[v]; Noe. Adjacency li include edge wih reidual capaciy. (reidual nework i repreened implicily)

Finding a hore augmening pah (cf. breadh-fir earch) Ford-Fulkeron: Java implemenaion privae boolean haaugmeningpah(flownework G, in, in ) edgeto = new FlowEdge[G.V()]; marked = new boolean[g.v()]; Queue<Ineger> queue = new Queue<Ineger>(); queue.enqueue(); marked[] = rue; while (!queue.iempy()) in v = queue.dequeue(); for (FlowEdge e : G.adj(v)) found pah from o w in he reidual nework? in w = e.oher(v); if (!marked[w] && (e.reidualcapaciyto(w) > ) ) edgeto[w] = e; marked[w] = rue; queue.enqueue(w); ave la edge on pah o w; mark w; add w o he queue public cla FordFulkeron privae boolean[] marked; // rue if ->v pah in reidual nework privae FlowEdge[] edgeto; // la edge on ->v pah privae double value; // value of flow public FordFulkeron(FlowNework G, in, in ) compue edgeto[] value =.; while (haaugmeningpah(g,, )) compue boleneck capaciy double bole = Double.POSITIVE_INFINITY; for (in v = ; v!= ; v = edgeto[v].oher(v)) bole = Mah.min(bole, edgeto[v].reidualcapaciyto(v)); for (in v = ; v!= ; v = edgeto[v].oher(v)) edgeto[v].addreidualflowto(v, bole); value += bole; privae boolean haaugmeningpah(flownework G, in, in ) /* See previou lide. */ public double value() reurn value; augmen flow reurn marked[]; i reachable from in reidual nework? public boolean incu(in v) reurn marked[v]; i v reachable from in reidual nework? Maxflow and mincu applicaion Maxflow/mincu i a widely applicable problem-olving model. Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp://alg.c.princeon.edu. MAXIMUM FLOW inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion Daa mining. Open-pi mining. Biparie maching. Nework reliabiliy. Baeball eliminaion. Image egmenaion. Nework conneciviy. Diribued compuing. Securiy of aiical daa. Egaliarian able maching. Muli-camera cene reconrucion. Senor placemen for homeland ecuriy. Many, many, more. liver and hepaic vacularizaion egmenaion

Biparie maching problem Biparie maching problem N uden apply for N job. Given a biparie graph, find a perfec maching. biparie maching problem perfec maching (oluion) biparie graph biparie maching problem Each ge everal offer. I here a way o mach all uden o job? Facebook Facebook Facebook N uden N companie Facebook Facebook Nework flow formulaion of biparie maching Creae,, one verex for each uden, and one verex for each job. Add edge from o each uden (capaciy ). Add edge from each job o (capaciy ). Add edge from uden o each job offered (infinie capaciy). flow nework biparie maching problem Nework flow formulaion of biparie maching - correpondence beween perfec maching in biparie graph and ineger-valued maxflow of value N. flow nework biparie maching problem N uden N companie Facebook Facebook N uden N companie Facebook Facebook

Wha he mincu ell u Wha he mincu ell u Goal. When no perfec maching, explain why. Mincu. Conider mincu (A, B). Le S = uden on ide of cu. Le T = companie on ide of cu. Fac: S > T ; uden in S can be mached only o companie in T. S =,, T =, S =,, T =, uden in S can be mached only o companie in T S > T uden in S can be mached only o companie in T S > T no perfec maching exi no perfec maching exi Boom line. When no perfec maching, mincu explain why. Baeball eliminaion problem Baeball eliminaion problem Q. Which eam have a chance of finihing he eaon wih he mo win? Q. Which eam have a chance of finihing he eaon wih he mo win? i eam win loe o play ATL PHI NYM MON Alana Philly New York Monreal i eam win loe o play ATL PHI NYM MON Alana Philly New York Monreal Monreal i mahemaically eliminaed. Monreal finihe wih win. Alana already ha win. Philadelphia i mahemaically eliminaed. Philadelphia finihe wih win. Eiher New York or Alana will finih wih win. Obervaion. Anwer depend no only on how many game already won and lef o play, bu on whom hey're again.

Baeball eliminaion problem Baeball eliminaion problem: maxflow formulaion Q. Which eam have a chance of finihing he eaon wih he mo win? Inuiion. Remaining game flow from o. i eam win loe o play NYY BAL BOS TOR DET New York Balimore game lef beween and eam can ill win hi many more game Boon Torono Deroi g w + r w AL Ea (Augu, ) Deroi i mahemaically eliminaed. Deroi finihe wih win. Win for R = NYY, BAL, BOS, TOR =. Remaining game among NYY, BAL, BOS, TOR = + + + + =. Average eam in R win / =. game. game verice (each pair of eam oher han ) eam verice (each eam oher han ) Fac. Team no eliminaed iff all edge poining from are full in maxflow. Maximum flow algorihm: heory Maximum flow algorihm: pracice (Ye anoher) holy grail for heoreical compuer cieni. Warning. Wor-cae order-of-growh i generally no ueful for predicing year mehod wor cae dicovered by or comparing maxflow algorihm performance in pracice. implex E U Danzig augmening pah E U Ford-Fulkeron Be in pracice. Puh-relabel mehod wih gap relabeling: E /. hore augmening pah E Diniz, Edmond-Karp fae augmening pah E log E log( E U ) Diniz, Edmond-Karp blocking flow E / Cherkaky blocking flow E / Galil dynamic ree E log E Sleaor-Tarjan capaciy caling E log U Gabow lengh funcion E / log E log U Goldberg-Rao compac nework E / log E Orlin?? E? On Implemening Puh-Relabel Mehod for he Maximum Flow Problem Bori V. Cherkaky and Andrew V. Goldberg Cenral Iniue for Economic and Mahemaic, Kraikova S.,, Mocow, Ruia cher@eemi.mk.u Compuer Science Deparmen, Sanford Univeriy Sanford, CA, USA goldberg ~c. anford, edu Abrac. We udy efficien implemenaion of he puh-relabel mehod for he maximum flow problem. The reuling code are faer han he previou code, and much faer on ome problem familie. The peedup i due o he combinaion of heuriic ued in our implemenaion. We alo exhibi a family of problem for which he running ime of all known mehod eem o have a roughly quadraic growh rae. ELSEVIER European Journal of Operaional Reearch () - Theory and Mehodology EUROPEAN JOURNAL OF OPERATIONAL RESEARCH Compuaional inveigaion of maximum flow algorihm Ravindra K. Ahuja a, Murali Kodialam a b, Ajay K. Mihra c, Jame B. Orlin d,. Deparmen ~'lndurial and Managemen Engineering. Indian Iniue of Technology. Kanpur,, India b AT& T Bell Laboraorie, Holmdel, NJ, USA c KA'F-Z Graduae School of Buine, Univeriy of Piburgh, Piburgh, PA, USA d Sloun School of Managemen, Maachue Iniue of Technology. Cambridge. MA. USA Received Augu ; acceped June maxflow algorihm for pare digraph wih E edge, ineger capaciie beween and U

Summary Mincu problem. Find an -cu of minimum capaciy. Maxflow problem. Find an -flow of maximum value. Dualiy. Value of he maxflow = capaciy of mincu. Proven ucceful approache. Ford-Fulkeron (variou augmening-pah raegie). Preflow-puh (variou verion). Open reearch challenge. Pracice: olve real-world maxflow/mincu problem in linear ime. Theory: prove i for wor-cae inpu. Sill much o be learned!