directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time

Similar documents
Two Applications of Maximum Flow

Max Flow: Algorithms and Applications

Running Time. Assumption. All capacities are integers between 1 and C.

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

Algorithms: Lecture 12. Chalmers University of Technology

Algorithms and Theory of Computation. Lecture 11: Network Flow

Maximum Flow. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Maximum Flow 1 / 27

Flows and Cuts. 1 Concepts. CS 787: Advanced Algorithms. Instructor: Dieter van Melkebeek

Algorithm Design and Analysis

Agenda. Soviet Rail Network, We ve done Greedy Method Divide and Conquer Dynamic Programming

CMPSCI 611: Advanced Algorithms

Today. Flow review. Augmenting paths. Ford-Fulkerson Algorithm. Intro to cuts (reason: prove correctness)

Algorithm Design and Analysis

6.046 Recitation 11 Handout

Mathematics for Decision Making: An Introduction. Lecture 13

10 Max-Flow Min-Cut Flows and Capacitated Graphs 10 MAX-FLOW MIN-CUT

Flow Network. The following figure shows an example of a flow network:

Lecture 2: Network Flows 1

Maximum flow problem (part I)

1 Review for Lecture 2 MaxFlow

Network Flows made simple

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Lecture 21 November 11, 2014

Maximum Flow. Reading: CLRS Chapter 26. CSE 6331 Algorithms Steve Lai

Lecture 3. 1 Polynomial-time algorithms for the maximum flow problem

Algorithms: COMP3121/3821/9101/9801

The max flow problem. Ford-Fulkerson method. A cut. Lemma Corollary Max Flow Min Cut Theorem. Max Flow Min Cut Theorem

Types of Networks. Internet Telephone Cell Highways Rail Electrical Power Water Sewer Gas

ORIE 633 Network Flows October 4, Lecture 10

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

Graph Algorithms -2: Flow Networks. N. H. N. D. de Silva Dept. of Computer Science & Eng University of Moratuwa

Lecture 2: Divide and conquer and Dynamic programming

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

The maximum flow problem

Computer Science & Engineering 423/823 Design and Analysis of Algorithms

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Chapter 7 Network Flow Problems, I

CMPSCI 311: Introduction to Algorithms Second Midterm Exam

CSCE423/823. Introduction. Flow Networks. Ford-Fulkerson Method. Edmonds-Karp Algorithm. Maximum Bipartite Matching 2/35 CSCE423/823.

CS 1501 Recitation. Xiang Xiao

Flows. Chapter Circulations

Standard Diraphs the (unique) digraph with no vertices or edges. (modulo n) for every 1 i n A digraph whose underlying graph is a complete graph.

2.13 Maximum flow with a strictly positive initial feasible flow

Maximum flow problem CE 377K. February 26, 2015

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

5 Flows and cuts in digraphs

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Soviet Rail Network, 1955

C&O 355 Mathematical Programming Fall 2010 Lecture 18. N. Harvey

Internet Routing Example

1 Matroid intersection

Breadth-First Search of Graphs

Lecture 8 Network Optimization Algorithms

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

MAS210 Graph Theory Exercises 5 Solutions (1) v 5 (1)

Maximum flow problem

Algorithm Design and Analysis

Lecture 2: Just married

Discrete Optimization 2010 Lecture 3 Maximum Flows

The min cost flow problem Course notes for Search and Optimization Spring 2004

Cographs; chordal graphs and tree decompositions

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

The min cost flow problem Course notes for Optimization Spring 2007

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Network Flows. 4. Maximum Flows Problems. Fall 2010 Instructor: Dr. Masoud Yaghini

Chapter 7. Network Flow. CS 350: Winter 2018

1 Some loose ends from last time

CSC 373: Algorithm Design and Analysis Lecture 12

Graphs and Network Flows IE411. Lecture 12. Dr. Ted Ralphs

Graphs and Network Flows IE411. Lecture 15. Dr. Ted Ralphs

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

Math 5707: Graph Theory, Spring 2017 Midterm 3

1 Matchings in Non-Bipartite Graphs

Observation 4.1 G has a proper separation of order 0 if and only if G is disconnected.

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

The Budget-Constrained Maximum Flow Problem

Robust Network Codes for Unicast Connections: A Case Study

Part V. Matchings. Matching. 19 Augmenting Paths for Matchings. 18 Bipartite Matching via Flows

Introduction to Graph Theory

CSE 202 Homework 4 Matthias Springer, A

Midterm Exam 2 Solutions

Basics on the Graphcut Algorithm. Application for the Computation of the Mode of the Ising Model

Introduction 1.1 PROBLEM FORMULATION

Exposition of the Dinitz algorithm

(1,3) (3,4) (2,2) (1,2) (2,4) t

MA015: Graph Algorithms

2. A vertex in G is central if its greatest distance from any other vertex is as small as possible. This distance is the radius of G.

Energy minimization via graph-cuts

R(p, k) = the near regular complete k-partite graph of order p. Let p = sk+r, where s and r are positive integers such that 0 r < k.

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Recall: Matchings. Examples. K n,m, K n, Petersen graph, Q k ; graphs without perfect matching

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Maximum Integer Flows in Directed Planar Graphs with Multiple Sources and Sinks and Vertex Capacities

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Discrete Optimization

MATH 409 LECTURES THE KNAPSACK PROBLEM

On shredders and vertex connectivity augmentation

Parallel Graph Algorithms (con4nued)

ACO Comprehensive Exam 19 March Graph Theory

CSE 421 Introduction to Algorithms Final Exam Winter 2005

Transcription:

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm CS 401/MCS 401 Lecture 15 Computer Algorithms I Jan Verschelde, 23 July 18 Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 1 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 2 / 46

directed weighted graphs as flow networks A flow network is defined by a weighted directed graph G = (V, E): s u 30 t s is the only source node t is the only sink node each edge has a capacity nodes other than s or t are internal nodes v V = { s, u, v, t } E = { (s, u, ), (s, v, ), (u, v, 30), (v, t, ), (u, t, ) } Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 3 / 46

defining flow Let G = (V, E) be a weighted directed graph with a source s, sink t, and capacities c e for each e E. An s-t flow is a function f f : E R + : e f (e), where f (e) is the amount of flow carried by edge e. Each flow must satisfy the following two properties: 1 Capacity conditions: for each e E: f (e) c e. 2 Conservation conditions: for each internal node v: f (e) = f (e) e into v e out of v By the capacity conditions, the flow carried by each edge cannot be larger than the capacity of the edge. The conservation conditions state that internal nodes do not leak. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 4 / 46

the value of a flow The source has no incoming edges, but generates flow. The sink has no outgoing edges, but absorbs flow. Given a flow f, the value v(f ) of the flow f is v(f ) = We denote: f out (v) = e out of v f (e) and f in (v) = e into v e out of s f (e). f (e). Then : v(f ) = f out (s). The conservation laws for internal nodes v are f in (v) = f out (v). For sets S V : f out (S) = e out of S f (e) and f in (S) = e into S f (e). Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 5 / 46

the maximum flow problem Given is G = (V, E), a weighted directed graph with a single source s V, a single sink t V, and capacities c e for each e E. The maximum flow problem asks for an s-t flow f with the largest value v(f ) over all possible s-t flows. As we solve the maximum flow problem, we will identify the edge that has the capacity which bounds the maximum flow. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 6 / 46

uniqueness of the maximum flow problem Exercise 1: Is the solution to the maximum flow problem unique? Justify your anwers with examples. Formulate conditions on the input data for a solution to be or not to be unique. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 7 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 8 / 46

design of the algorithm We push a flow of : f ((s, u)) =, f ((u, v)) =, f ((v, t)) = : u u s 30 t s 30 t v v Is this the maximum possible flow for this network? Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 9 / 46

computing an augmenting path Given the flow f ((s, u)) =, f ((u, v)) =, f ((v, t)) = : u u s 30 t s 30 t v v We want to undo units of flow from u to v. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 / 46

the residual graph and the bottleneck Given a network G = (V, E) with flow f on G, the residual graph G f = (V f, E f ) of G with respect to f has the same vertices as G: V f = V, for e E: f (e) < c e, the forward edge (u, v) E f has capacity c e f (e), for e E: f (e) > 0, the backward edge (v, u) E f has capacity f (e). Note: #E f 2#E. The capacity of an edge in G f is a residual capacity. Given an s-t path P in G f without repeat nodes, we define bottleneck(p, f ) to be the minimum residual capacity of any edge on P with respect to the flow f. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 11 / 46

a residual graph u u s 30 t s t v v The dashed arrows define the augmenting path. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 12 / 46

the operation augment(f, P) augment(f, P) Input: f, the flow on a network G, P, an s-t path without repeat nodes. Output: returns a new flow f. b := bottleneck(p, f ) f := f for each edge (u, v) P do if (u, v) is a forward edge in G f then f ((u, v)) := f ((u, v)) + b else (we have a backward edge) f ((v, u)) := f ((v, u)) b return f Any s-t path in G f is an augmenting path. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 13 / 46

Lemma f = augment(f, P) is a flow. Proof. We verify the capacity and conservation conditions on f. It suffices to consider only the edges on P, as the rest of G was not changed by the operation augment. Let b = bottleneck(p, f ). Consder e an edge on P. 1 Either e is a forward edge in G f : f (e) = f (e) + b f (e) + (c e f (e)) = c e, so the capacity condition f (e) c e holds. 2 Or e is a backward edge in G f, let e = (u, v). c (v,u) f ((v, u)) f ((v, u)) = f ((v, u)) b, As b f ((v, u)) and b 0: f ((v, u)) c (v,u). Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 14 / 46

proof continued: the conservation conditions on f On an internal node v, we have f in (v) = f out (v), because f is a flow and satifies the conservation conditions. We must show that (f ) in (v) = (f ) out (v). For an edge e on P, there are four cases to consider: 1 e enters v 1 e is a forward edge 2 e is a backward edge 2 e exits v 1 e is a forward edge 2 e is a backward edge Exercise 2: Work out the four cases to verify the conservation conditions. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 15 / 46

the Ford-Fulkerson algorithm Max-Flow(G) Input: G = (V, E), a flow network. Output: the maximum flow f. for all e E: f (e) := 0 while there is an s-t path in G f do let P be an s-t path with no repeat nodes in G f f := augment(f, P) return f Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 16 / 46

augmenting the flow u u s t s 30 t v v Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 17 / 46

the residual graph u u s 30 t s t v v Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 18 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 19 / 46

integer capacities imply integer flows Lemma If G has nonnegative integer values for each capacity, then at any stage of Max-Flow, the values f (e) and the residual capacities in G f are nonnegative integers. Proof. We proceed by induction. Initially f (e) = 0 for all edges e. Induction hypothesis: for all up to the k-th stage in Max-Flow, all f (e) and residual capacities are nonnegative integer numbers. We show that the lemma holds for stage k + 1. The value for bottleneck(p, f ) is a nonnegative integer because, by the induction hypothesis, all residual capacities are nonnegative integers. Thus augment(f, P) will return a flow with nonnegative integer values and also at stage k + 1 does the statement of the lemma hold. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 / 46

the flow value strictly increases Lemma Let f be a flow in G and P be an s-t path with no repeat nodes in G f. If bottleneck(p, f ) > 0, then v(f ) > v(f ) for f = augment(f, P). Proof. As bottleneck(p, f ) > 0, the first edge e on P in G f must be out of s. As P has no repeat nodes, P does not visit s again. In a flow network G, the source s has no edges entering s. Therefore, this first edge e must be a forward edge. The flow on e is increased by bottleneck(p, f ) and the flow on other edges incident to s does not change. Therefore, v(f ) = v(f ) + bottleneck(p, f ). Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 21 / 46

the algorithm terminates Define the upper bound: C = Theorem e out of s If all capacities in the flow network are nonnegative integers, then the while loop in Max-Flow terminates in at most C iterations. c e. Proof. For all s-t flows f, we have v(f ) C. By the previous Lemma, the value of the flow increases in each step. By the Lemma before the previous Lemma, all flow values are nonnegative integers, so the increase is at least one in each iteration. As the flow values start at zero and cannot go higher than C, the while loop runs for at most C iterations. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 22 / 46

adjacency list representation 0 1 30 3 0 1 2 1, 2, 2, 30 3, 3, 0 1 2 0, 0, 1, 30 3 3 1, 2, 2 For every vertex, we have two lists: (1) vertices to which it has edges (2) vertices from which it has edges Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 23 / 46

the running time Assume that all nodes have at least one incident edge in G = (V, E), then m n/2, for m = #E and n = #V. Theorem If all capacities on the m edges in the flow network are nonnegative integers, then Max-Flow can be implemented to run in O(mC) time. Proof. By the previous Theorem, Max-Flow does at most C iterations. We consider the work in each iteration. 1 G f has at most 2m edges and is stored in an adjacency list representation. To find an s-t path, breadth-first or depth-first search runs in O(m + n) time. By the assumption m n/2, O(m + n) is O(m). 2 The cost of augment(f, P) is O(n) as the path P has no repeat nodes and thus at most n 1 edges. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 24 / 46

proof of the running time continued 3 Given the new flow computed by augment(f, P), the construction of G f runs in O(m): for each edge of G, we construct the forward and backward edges of G f. The number of operations per iteration is bounded by O(m). Since we have at most C iterations, Max-Flow runs in O(mC) time. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 25 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 26 / 46

flows and cuts The bound C = Definition e out of s c e on v(f ) is often too high. Given a flow network G = (V, E), an s-t cut is a partition of V into A and B such that s A and t B, denoted by cut(a, B). Definition Given a flow network G = (V, E), the capacity of cut(a, B) is c(a, B) = e out of A c e. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 27 / 46

value of a flow and flow across a cut Lemma For any s-t flow f and any cut(a, B), an s-t cut: v(f ) = f out (A) f in (A). Proof. By definition, v(f ) = f out (s) and f in (s) = 0 as the source s has no incoming edges. Thus: v(f ) = f out (s) f in (s). By the conservation conditions, for all internal nodes v, f out (v) f in (v) = 0. Thus, v(f ) = v A ( f out (v) f in (v) ). If an edge e has both its vertices in A, then f (e) appears once in the positive and once in the negative part of the sum above. So we may restrict the sum to the other edges: ( f out (v) f in (v) ) = f (e) f (e) = f out (A) f in (A). v A e out of A e into A Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 28 / 46

a bound on the value of the flow Since a cut is a partition of the vertex set: edges out of A go into B, so f out (A) = f in (B), and edges into A go out of B, so f in (A) = f out (B). So we can rewrite v(f ) = f out (A) f in (A) as v(f ) = f in (B) f out (B). Corollary For any s-t flow f and any s-t cut cut(a, B): v(f ) c(a, B). Proof. v(f ) = f out (A) f in (A) f out (A) and f out (A) = f (e) c e = c(a, B). e out of A e out of A Q.E.D. The value of every flow is bounded by the capacity of every cut. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 29 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 30 / 46

Max-Flow returns the maximum flow If there is no s-t path in G f, then Max-Flow terminates. Theorem If f is an s-t flow such that there is no s-t path in G f, then there is an s-t cut (A, B ) for which v(f ) = c(a, B ), where v(f ) is the maximal flow and c(a, B ) is the minimum capacity. Proof. Let A = { v V there is an s-v path in G f }. Set B = V \ A. We verify that (A, B ) is a cut. By construction, A and B partition V and s A. Because there is no s-t path in G f, t B. Consider G f : u A B v v u Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 31 / 46

two claims about f ((u, v)) and f ((u, v )) G f : u A B v f ((u, v)) = c (u,v) v u f ((u, v )) = 0 1 For any (u, v) with u A and v B : f ((u, v)) = c (u,v). By contradiction, assume f ((u, v)) < c (u,v). Then (u, v) is a forward edge. As u A, we can extend the s-u path with v, but as v B, this is a contradiction. 2 For any (u, v ) with u B and v A : f ((u, v )) = 0. By contraction, assume f ((u, v )) > 0. Then (u, v ) is a backward edge. As v A, we can extend the s-v path with u, but as u B, this is a contradiction. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 32 / 46

proof continued By the Lemma, for any s-t flow f and any cut(a, B), an s-t cut: v(f ) = f out (A) f in (A). v(f ) = f out (A ) f in (A ) = f (e) f (e) e out of A e into A = f (e) 0 e out of A = cut(a, B). Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 33 / 46

optimality Corollary The flow returned by Max-Flow is a maximum flow. Corollary Given a flow with maxium value, we can compute an s-t cut of minimum capacity in O(m) time. Proof. We follow the proof of the previous theorem. We construct G f and run a breadth-first or depth-first search to compute A, the set of all nodes that can be reached from s. This computation runs in O(m + n) time, or in time O(m) as m n/2. The set B is obtained as the complement of A with respect to V : B = V \ A. Q.E.D. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 34 / 46

the Max-Flow Min-Cut Theorem Corollary In every flow network, there is a flow f and a cut (A, B) so that v(f ) = c(a, B). Theorem In every flow network, the maximum value of an s-t flow is equal to the minimum capacity of an s-t cut. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 35 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 36 / 46

an example We push a flow of 1: f ((s, u)) = 1, f ((u, v)) = 1, f ((v, t)) = 1: u u 0 0 0 1 0 s 1 t s 1 1 t 0 0 0 1 0 v v Observe that the bound C is 0 for this network. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 37 / 46

the residual graph The bottleneck(p, f ) = 1: u u 0 1 0 99 1 0 s 1 1 t s 1 t 0 1 0 0 1 v v The dashed arrows indicate the augmenting path. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 38 / 46

the next step After the next step, the bottleneck(p, f ) = 1 again: u u 0 1 1 0 99 1 1 99 s 1 0 1 t s 1 0 99 1 1 99 1 t v v The dashed arrows indicate the augmenting path. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 39 / 46

the next steps... s u 0 2 1 1 0 1 v 1 2 0 0 t The next augmenting path will again go along (v, u). In total 0 augmentations will be needed if in every step we choose (v, u) or (u, v) in the augmenting path. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 40 / 46

Network Flow 1 The Maximum-Flow Problem directed weighted graphs as flow networks the Ford-Fulkerson algorithm termination and running time 2 Maximum Flows and Minimum Cuts flows and cuts max flow equals min cut 3 Choosing Good Augmenting Paths an example with a large number of iterations the scaling max-flow algorithm Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 41 / 46

the scaling max-flow algorithm Scaling Max-Flow(G) Input: G = (V, E), a flow network. Output: the maximum flow f. for all e E: f (e) := 0 C := e out of s c e := the largest power of 2 that is no larger than C while 1 do while there is an s-t path in G f ( ) do let P be an s-t path with no repeat nodes in G f ( ) f := augment(f, P) := /2 return f Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 42 / 46

termination and optimality The termination property of the Max-Flow algorithm extends. Theorem If all capacities are integer numbers, then throughout the Scaling Max-Flow algorithm the flow and the residual capacities are integer numbers. This implies that when = 1, G f ( ) is the same as G f, and hence when the algorithm terminates the flow f, is of maximum value. The -scaling phase is the outer loop of Scaling Max-Flow. The value of is at most C and then drops by factors of 2. The value of never gets below 1. Lemma The number of iterations in the outer loop of Scaling Max-Flow is at most log 2 (C). Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 43 / 46

on the number of augmentations During the -scaling phase, we use only edges with residual capacity of at least. Lemma During the -scaling phase, each augmentation increases the flow value by at least. At the end of the -scaling phase, the flow f cannot be too far from the maximum possible value. Theorem Let f be the flow at the end of the -scaling phase. There is an s-t cut(a, B) in G for which c(a, B) v(f ) + m, where m is the number of edges in the graph G. Consequently, the maximum flow in the network has value at most v(f ) + m. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 44 / 46

the running time of Scaling Max-Flow Lemma The number of augmentations in a scaling phase is at most 2m. We have at most log 2 (C) scaling phases and at most 2m augmentations in each scaling phase. Theorem The Scaling Max-Flow algorithm in a graph with m edges and integer capacities finds a maximum flow in at most 2m(1 + log 2 (C) ) augmentations. It can be implemented to run in at most O(m 2 log 2 (C)) time. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 45 / 46

pseudo polynomial and strongly polynomial time Recall that the subset sum and knapsack problems could be solved in O(nW ) time for n weights with upper bound W on their sum. The Ford-Fulkerson algorithm has a similar running time: O(mC) for a network with m edges and C the sum of all capacities. Algorithms with a cost polynomial in the dimensions of the input and in the size of the numbers in the input data are called pseudo polynomial. Algorithms with a cost polynomial in the dimensions of the input and with numbers which size is polynomial in the number of bits are called strongly polynomial. Computer Algorithms I (CS 401/MCS 401) Network Flow L-15 23 July 18 46 / 46