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

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

CSE 421 Introduction to Algorithms Winter The Network Flow Problem

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

Maximum Flow and Minimum Cut

Today: Max Flow Proofs

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

Algorithm Design and Analysis

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

Matching. Slides designed by Kevin Wayne.

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

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

Algorithms. Algorithms 6.4 MIN CUT / MAX FLOW

Main Reference: Sections in CLRS.

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

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

Algorithm Design and Analysis

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

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Algorithms. Algorithms 6.4 MAXIMUM FLOW

Graphs III - Network Flow

Algorithmic Discrete Mathematics 6. Exercise Sheet

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

CSE 521: Design & Analysis of Algorithms I

16 Max-Flow Algorithms and Applications

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

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

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.

Randomized Perfect Bipartite Matching

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

Reminder: Flow Networks

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

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

Network Flow. Data Structures and Algorithms Andrei Bulatov

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

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

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

Network Flows UPCOPENCOURSEWARE number 34414

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

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

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

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

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

23 Maximum Flows and Minimum Cuts

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

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

Introduction to Congestion Games

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

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

16 Max-Flow Algorithms

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

Network Flow Applications

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

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

Average Case Lower Bounds for Monotone Switching Networks

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

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

Graph Theory: Network Flow

FLAT CYCLOTOMIC POLYNOMIALS OF ORDER FOUR AND HIGHER

Research Article On Double Summability of Double Conjugate Fourier Series

Stationary Distribution. Design and Analysis of Algorithms Andrei Bulatov

Introduction to SLE Lecture Notes

18.03SC Unit 3 Practice Exam and Solutions

An introduction to the theory of SDDP algorithm

, 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

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

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

Random Walk with Anti-Correlated Steps

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

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

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

The Primal Simplex Approach to the QoS Routing Problem

Geometric Path Problems with Violations

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

arxiv: v1 [cs.cg] 21 Mar 2013

Macroeconomics 1. Ali Shourideh. Final Exam

CHAPTER 7: SECOND-ORDER CIRCUITS

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

CS261: A Second Course in Algorithms Lecture #1: Course Goals and Introduction to Maximum Flow

To become more mathematically correct, Circuit equations are Algebraic Differential equations. from KVL, KCL from the constitutive relationship

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

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, wih in one e A and in he oher e B. 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. 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 = + + = Maxflow: quiz Mincu applicaion (RAND ) Wha i he capaciy of he -cu A, E, F, G? "Free world" goal. Cu upplie (if cold war urn ino real war). A. ( + + + ) B. ( + ) C. ( + + + + + ) D. I don' know. ource capaciy A B C D E F G H ink rail nework connecing Sovie Union wih Eaern European counrie (map declaified by Penagon in )

Poenial mincu applicaion () Maxflow problem Governmen-in-power goal. Cu off communicaion o e of people. Efficien Maximum Flow Algorihm by Andrew Goldberg and Tarjan hp:vimeo.com Maxflow problem Maxflow problem Inpu. An edge-weighed digraph, ource verex, and arge verex. 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 ). each edge ha a poiive capaciy capaciy flow capaciy inflow a v = + + = ouflow a v = + v =

Maxflow problem Maxflow problem Def. An -flow (flow) i an aignmen of value o he edge uch ha: 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 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. 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.. MAXIMUM FLOW value of flow = capaciy of cu = Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp:alg.c.princeon.edu inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion Remarkable fac. Thee wo problem are dual! 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

Maxflow: quiz Ford-Fulkeron algorihm Which i an augmening pah of highe boleneck capaciy? A. A F G H B. A F B G H C. A F B G D H D. I don' know. 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 ource A B flow capaciy C D Fundamenal queion. How o compue a mincu? How o find an augmening pah? If FF erminae, doe i alway compue a maxflow? Doe FF alway erminae? If o, afer how many augmenaion? E F G H ink 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.. MAXIMUM FLOW Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp:alg.c.princeon.edu inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion ne flow acro cu = + + = 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. 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 = ( + + + + + ) ( + + + ) = edge from B o A value of flow = value of flow = Relaionhip beween flow and cu Relaionhip beween flow and cu 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. 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. Inuiion. Conervaion of flow. Pf. Value of flow f = ne flow acro cu (A, B) capaciy of cu (A, B). 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. flow-value lemma flow bounded by capaciy Corollary. Ouflow from = inflow o = value of flow. 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. Maxflow-mincu heorem. Value of he maxflow = capaciy of mincu. Augmening pah heorem. A flow f i a maxflow iff no augmening pah. Maxflow-mincu heorem. Value of he maxflow = capaciy of mincu. 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. 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 [ 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. Maxflow-mincu heorem Compuing a mincu from a maxflow [ iii i ] Le f be a flow wih no augmening pah. Le A be e of verice conneced o by an undireced pah wih no full forward or empy backward edge By definiion of cu A, i in A. By definiion of cu A and flow f, i in B. Capaciy of cu = ne flow acro cu = value of flow f. G A backward edge from B o A (flow = ) B 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. flow-value lemma A forward edge from A o B (flow = capaciy) forward edge (no full) backward edge (no empy) full forward edge empy backward edge

Ford-Fulkeron algorihm Ford-Fulkeron algorihm 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 Fundamenal queion. How o compue a mincu? Eay. How o find an augmening pah? BFS work well. 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? 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 Ford-Fulkeron algorihm wih ineger capaciie Bad cae for Ford-Fulkeron Imporan pecial cae. Edge capaciie are ineger beween and U. flow on each edge i an ineger Bad new. Even when edge capaciie are ineger, number of augmening pah could be equal o he value of he maxflow. Invarian. The flow i inegral hroughou Ford-Fulkeron. Pf. [by inducion] Boleneck capaciy i an ineger. Flow on an edge increaedecreae by boleneck capaciy. Propoiion. Number of augmenaion he value of he maxflow. iniialize wih flow flow capaciy Pf. Each augmenaion increae he value by a lea. criical for ome applicaion (ay uned) Inegraliy heorem. There exi an inegral 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. ieraion nd 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. rd ieraion 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... 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. can be exponenial in inpu ize Good new. Thi cae i eaily avoided. [ ue horefae pah ] h ieraion

w v How o chooe augmening pah? How o chooe augmening pah? Chooe augmening pah wih: Shore pah: fewe number of edge. Fae pah: max boleneck capaciy. Ue care when elecing augmening pah. Some choice lead o exponenial algorihm. Clever choice lead o polynomial algorihm. augmening pah number of pah implemenaion Theoreical Improvemen in Algorihmic Efficiency for Nework Flow Problem random pah E U randomized queue DFS pah E U ack (DFS) 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. hore pah ½ E V queue (BFS) fae pah E ln(e U) prioriy queue flow nework wih V verice, E edge, and ineger capaciie beween and U Edmond-Karp (USA) Dinic (Sovie Union) Flow nework repreenaion Flow edge daa ype. Aociae flow f e and capaciy c e wih edge e = v w. flow fe capaciy ce. MAXIMUM FLOW Algorihm ROBERT SEDGEWICK KEVIN WAYNE hp:alg.c.princeon.edu inroducion Ford-Fulkeron algorihm maxflow-mincu heorem analyi of running ime Java implemenaion applicaion 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 (pare) capaciy. Forward edge: reidual capaciy = ce fe. Backward edge: reidual capaciy = fe. Augmen flow. Forward edge: add. Backward edge: ubrac. reidual capaciy w v forward edge backward edge

w w v v Flow nework repreenaion Flow edge API Reidual nework. A ueful view of a flow nework. include all edge wih poiive reidual capaciy public cla FlowEdge original nework 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 reidual nework backward edge (no empy) 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 Key poin. Augmening pah in original nework are in one-o-one correpondence wih direced pah in reidual nework. forward edge (no full) flow fe capaciy ce reidual capaciy v forward edge w backward edge Flow edge: Java implemenaion Flow edge: Java implemenaion (coninued) 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; public in from() reurn v; public in o() reurn w; public double capaciy() reurn capaciy; public double flow() reurn flow; flow variable (muable) 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 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 flow fe capaciy ce reidual capaciy v forward edge w backward edge

Flow nework API Flow nework: Java implemenaion 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 ofrom v Ierable<FlowEdge> edge() all edge in hi flow nework in V() number of verice in E() number of edge Sring osring() ring 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 Convenion. Allow elf-loop and parallel edge. public Ierable<FlowEdge> adj(in v) reurn adj[v]; Flow nework: adjacency-li repreenaion Finding a hore augmening pah (cf. breadh-fir earch) Mainain verex-indexed array of FlowEdge li (ue Bag abracion). inyfn.x V E........ adj[]........ Noe. Adjacency li include edge wih reidual capaciy. (reidual nework i repreened implicily) reference o he ame FlowEdge objec........................ Bag objec 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) > ) ) reurn marked[]; edgeto[w] = e; marked[w] = rue; queue.enqueue(w); ave la edge on pah o w; mark w; add w o he queue i reachable from in reidual nework?

Ford-Fulkeron: Java implemenaion 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[] and marked[] value =.; while (haaugmeningpah(g,, )) compue double bole = Double.POSITIVE_INFINITY; boleneck capaciy 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 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 public boolean incu(in v) reurn marked[v]; i v reachable from in reidual nework? Maxflow and mincu applicaion Biparie maching problem Maxflowmincu i a widely applicable problem-olving model. N uden apply for N job. 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 Each ge everal offer. I here a way o mach all uden o job? biparie maching problem Facebook Facebook

Biparie maching problem Given a biparie graph, find a perfec maching. perfec maching (oluion) biparie graph biparie maching problem 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 Facebook N uden N companie Facebook Facebook N uden N companie Facebook Facebook Nework flow formulaion of biparie maching Wha he mincu ell u - correpondence beween perfec maching in biparie graph and ineger-valued maxflow of value N. Goal. When no perfec maching, explain why. flow nework biparie maching problem N uden N companie Facebook Facebook no perfec maching exi S =,, T =, uden in S can be mached only o companie in T S > T

Wha he mincu ell u Baeball eliminaion problem 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. Q. Which eam have a chance of finihing he eaon wih he mo win? i eam win loe o play ATL PHI NYM WAS Alana Philly New York S =,, T =, Wahingon uden in S can be mached only o companie in T S > T Wahingon i mahemaically eliminaed. Wahingon finihe wih win. Alana already ha win. 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 WAS Alana Philly New York Wahingon i eam win loe o play NYY BAL BOS TOR DET New York Balimore Boon Torono Deroi AL Ea (Augu, ) 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. 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.

Baeball eliminaion problem: maxflow formulaion Maximum flow algorihm: heory Inuiion. Remaining game flow from o. (Ye anoher) holy grail for heoreical compuer cieni. year mehod wor cae dicovered by implex E U Danzig game lef beween and eam can ill win hi many more game augmening pah E U Ford-Fulkeron hore augmening pah E Diniz, Edmond-Karp g w + r w 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 game verice (each pair of eam oher han ) eam verice (each eam oher han ) capaciy caling E log U Gabow lengh funcion E log E log U Goldberg-Rao compac nework E log E Orlin Fac. Team no eliminaed iff all edge poining from are full in maxflow.?? E? maxflow algorihm for pare nework wih E edge, ineger capaciie beween and U Maximum flow algorihm: pracice Summary Warning. Wor-cae order-of-growh i generally no ueful for predicing Mincu problem. Find an -cu of minimum capaciy. or comparing maxflow algorihm performance in pracice. Maxflow problem. Find an -flow of maximum value. Dualiy. Value of he maxflow = capaciy of mincu. Be in pracice. Puh-relabel mehod wih gap relabeling: 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 Proven ucceful approache. Ford-Fulkeron (variou augmening-pah raegie). Preflow-puh (variou verion). Open reearch challenge. Pracice: olve real-world maxflowmincu problem in linear ime. Theory: prove i for wor-cae inpu. Sill much o be learned!