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

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

1 Review for Lecture 2 MaxFlow

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

Lecture 2: Network Flows 1

Algorithms: COMP3121/3821/9101/9801

CMPSCI 611: Advanced Algorithms

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

CS 1501 Recitation. Xiang Xiao

The min cost flow problem Course notes for Optimization Spring 2007

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

6.046 Recitation 11 Handout

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

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

Two Applications of Maximum Flow

Algorithms and Theory of Computation. Lecture 11: Network Flow

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

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)}

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

CSE 326: Data Structures Network Flow. James Fogarty Autumn 2007

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

CS 138b Computer Algorithm Homework #14. Ling Li, February 23, Construct the level graph

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

5 Flows and cuts in digraphs

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

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

Maximum flow problem

Algorithm Design and Analysis

Max Flow: Algorithms and Applications

Internet Routing Example

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

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

Network Flows made simple

Lecture 1. 1 Overview. 2 Maximum Flow. COMPSCI 532: Design and Analysis of Algorithms August 26, 2015

Mathematics for Decision Making: An Introduction. Lecture 13

CSC 373: Algorithm Design and Analysis Lecture 12

Parallel Graph Algorithms (con4nued)

2.13 Maximum flow with a strictly positive initial feasible flow

Algorithm Design and Analysis

An example of LP problem: Political Elections

CS 170 DISCUSSION 10 MAXIMUM FLOW. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17

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

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

Realization of set functions as cut functions of graphs and hypergraphs

Exposition of the Dinitz algorithm

Parallel Graph Algorithms (con4nued)

Review Questions, Final Exam

p 3 p 2 p 4 q 2 q 7 q 1 q 3 q 6 q 5

. CS711008Z Algorithm Design and Analysis. Lecture 10. Algorithm design technique: Network flow and its applications 1. Dongbo Bu

Algorithm Theory - Exercise Class

Algorithm Design and Analysis

Lecture 8 Network Optimization Algorithms

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Lexicographic Flow. Dexter Kozen Department of Computer Science Cornell University Ithaca, New York , USA. June 25, 2009

On shredders and vertex connectivity augmentation

The maximum flow problem

Soviet Rail Network, 1955

Multicommodity Flows and Column Generation

Discrete Optimization 23

Network Flows. CTU FEE Department of control engineering. March 28, 2017

Fractional and circular 1-defective colorings of outerplanar graphs

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

Coloring. Basics. A k-coloring of a loopless graph G is a function f : V (G) S where S = k (often S = [k]).

Constructive proof of deficiency theorem of (g, f)-factor

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

Energy minimization via graph-cuts

GRAPH ALGORITHMS Week 7 (13 Nov - 18 Nov 2017)

Flows. Chapter Circulations

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

CMSC 451: Max-Flow Extensions

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

Discrete Optimization 2010 Lecture 3 Maximum Flows

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.

Maximum flow problem CE 377K. February 26, 2015

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

Contents. Introduction

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 2: Just married

CSC2420: Algorithm Design, Analysis and Theory Spring (or Winter for pessimists) 2017

Relations Graphical View

On the Dynamic Chromatic Number of Graphs

6. Linear Programming

Graph Theory and Optimization Computational Complexity (in brief)

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

7.5 Bipartite Matching

CSC2420: Algorithm Design, Analysis and Theory Fall 2017

22 Max-Flow Algorithms

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

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

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

Symmetric chain decompositions of partially ordered sets

On a list-coloring problem

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

FACTOR GRAPH OF NON-COMMUTATIVE RING

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Network Flow Problems Luis Goddyn, Math 408

Selected partial inverse combinatorial optimization problems with forbidden elements. Elisabeth Gassner

The Budget-Constrained Maximum Flow Problem

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.

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

Transcription:

Maximum Flow 1

Flow Network The following figure shows an example of a flow network: 16 V 1 12 V 3 20 s 10 4 9 7 t 13 4 V 2 V 4 14 A flow network G = (V,E) is a directed graph. Each edge (u, v) E has a nonnegative capacity c(u, v) 0. c(u, v) is possibly not equal to c(v, u). By convention, we say c(u, v) = 0 if (u, v) / E. There is one source vertex and one sink vertex in a flow network. We denote them by s and t, respectively. 2

We want to find a flow with maximum value that flows from the source to the target. Maximum Flow is a very practical problem. Many computational problems can be reduced to a Maximum Flow problem. 3

A Flow For any vertex v, we assume that there is a path from s to v and a path from v to t. A flow in G is a function f : V V R that specifies the direct flow value between every two nodes. 11/16 V 1 12/12 V 3 15/20 s 10 1/4 4/9 7/7 t 8/13 V 2 V 4 11/14 4/4 f should satisfy the following three properties before it can be called as a flow. Capacity constraint: For all u, v V, f(u, v) c(u, v). Skew symmetry: For all u, v V, f(u, v) = f(v, u). Flow conservation: For all u V {s, t}, v V f(u, v) = 0. 4

If (u, v) / E and (v, u) / E, then c(u, v) = c(v, u) = 0. By capacity constraint, f(u, v) 0 and f(v, u) 0. By skey symmetry, f(u, v) 0 and f(v, u) 0. Therefore f(u, v) = f(v, u) = 0. If there is no edge between u and v, then there is no flow between u and v. 5

The value of the flow f, denoted by f, is defined by f = v V f(s, v). f is the total flow out of the source. Lemma 1. f = u V f(u, t). That is, the flow out of the source is equal to the flow into the sink. Proof. (1) u V v V (2) u V {s,t} (3) u {s,t} f(u, v) = 0. (Skew symmetry) v V v V f(u, v) = 0. (Flow conservation) f(u, v) = 0. (4) v V f(s, v) = v V f(t, v) = v V f(v, t). 6

Idea of the Ford-Fulkerson method The Ford-Fulkerson method is the standard method for solving a maximum-flow problem. The idea of the method is iterative improvement. We start with an arbitrary flow. Then we check whether an improvement is possible. Suppose we start with an empty flow. The improvement is a path from the source to the sink. What if the current flow is not empty? 7

Residual network We need to examine the residual capacity for each edge. We check whether there is a path s t such that all edges on the path have a positive residual capacity. If so, we increase the flow. If not, we have got a maximal solution. Given a flow network G. Let f be a flow. The residual capacity of (u, v) is given by c f (u, v) = c(u, v) f(u, v). The residual network induced by f is G f = (V, E f ), where E f = {(u, v) V V : c f (u, v) > 0}. If there is a path from s to t in the residual network, then there is room to improve the current flow. 8

A flow in a flow network and its residual network. 12/12 V1 V3 11/16 s 10 1/4 4/9 7/7 8/13 V 2 V 11/14 4 15/20 4/4 t s 5 8 11 5 12 V1 V3 11 3 5 7 4 3 V 2 V 4 11 15 5 4 t 9

Note that if both (u, v) and (v, u) are not in the original flow network G, neither (u, v) nor (v, u) can appear in the residual network. Therefore, E f 2 E. Let f be a flow in the residual network G f. We can define a new flow (f + f ) in G, as follows (f + f )(u, v) = f(u, v) + f (u, v). Lemma 2. f + f is a flow in G. Proof. We need to verify the three constraints: (1) Capacity constraint: (f + f )(u, v) c(u, v). (2) Skew symmetry: (f + f )(u, v) = (f + f )(v, u). (3) Flow conservation: For all u V {s, t}, v V (f + f )(u, v) = 0. 10

Lemma 3. The value of the new flow f + f is equal to total values of f and f. I.e., f + f = f + f. Proof. f + f = v V = v V (f + f )(s, v) (f(s, v) + f (s, v)) = v V f(s, v) + v V f (s, v)) = f + f 11

Augmenting path Given a flow network G = (V, E) and a flow f in G, an augmenting path is a simple path from s to t in the residual graph G f. An augmenting path admits some additional positive flow for each edge on the path. The residual capacity of an augmenting path p is defined as c f (p) = min{c f (u, v) : (u, v) is in p} c f (p) is the maximum amount of additional flow we can increase through path p. Lemma 4. Let G = (V, E) be a flow network, let f be a flow in G, and let p be an augmenting path in G f. Define a function f p : V V R by c f (p) if (u, v) is on p, f p (u, v) = c f (p) if (v, u) is on p, 0 otherwise. Then, f p is a flow in G f with value f p = c f (p) > 0. 12

A flow in a flow network and its residual network. 12/12 V1 V3 11/16 s 10 1/4 4/9 7/7 8/13 V 2 V 11/14 4 15/20 4/4 t s 5 8 11 5 12 V1 V3 11 3 5 7 4 3 V 2 V 4 11 15 5 4 t A new flow from the augmenting path and its residual network. s 11/16 12/13 10 12/12 V1 V3 1/4 7/7 9 V 2 V 11/14 4 19/20 4/4 t s 5 12 11 1 12 V1 V3 11 3 9 7 3 V 2 V 4 11 19 1 4 t 13

The basic Ford-Fulkerson algorithm Ford-Fulkerson(G,s,t) 1. for each edge (u, v) E 2. f[u, v] 0, f[v, u] 0. 3. while there exists a path p from s to t in the residual network G f 4. c f (p) min{c f (u, v) : (u, v) is in p}. 5. for each edge (u, v) in p 6. f[u, v] f[u, v] + c f (p) 7. f[v, u] f[u, v] The path p from s to t in the residual network G f is called the augmenting path. The augmenting path p defines a flow in G f. By adding this flow f p to the current flow f, we get a better flow f + f p with value f + f p. Figure 26.6 on p.726-627 of the textbook shows an example. 14

Is the solution optimal? We have found an intuitive algorithm to provide a maximal flow. But is this flow maximum? Although we cannot increase the current flow by augmenting paths, is it possible that we find a completely different flow which has a better value? It turns out that the solution found by the Ford-Fulkerson algorithm is the maximum one. But we want to prove it. 15

Working with flows Let f be a flow. The flow from one set of vertices, X, to another set Y, is defined by f(x, Y ) = x X y Y f(x, y). Lemma 5. Let G = (V,E) be a flow network and let f be a flow on G, then; (1) For all X V, f(x, X) = 0. (2) For all X,Y V, f(x, Y ) = f(y, X). (3) For all X, Y, Z V with X Y =, f(x Y, Z) = f(x, Z) + f(y, Z) and f(z, X Y ) = f(z, X) + f(z, Y ). Proof. 16

Cuts of flow networks A cut (S,T) in the flow network G = (V, E) is a partition of V into S and T = V S such that s S and t T. The net flow across the cut (S,T) is defined to be f(s, T) = f(u, v). u S v T The capacity of the cut (S,T) is defined to be c(s, T) = c(u, v). u S v T Obviously, f(s, T) c(s, T). 17

11/16 V 1 12/12 V 3 15/20 s 10 1/4 4/9 7/7 t 8/13 V 2 V 11/14 4 4/4 S T Lemma 6. Let f be a flow in flow network G. Let (S, T) be any cut of G. Then the net flow across (S, T) is f(s,t) = f. Proof. By flow conservation, we have f(s {s}, V ) = 0. Also, f(s,v ) = f(s, S) + f(s, T) = f(s,t). Therefore, f(s, T) = f(s,v ) = f(s {s}, V ) + f({s}, V ) = f({s}, V ) = f. Therefore, the maximum flow is bounded by the capacity of the minimum cut. 18

Theorem 1. If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1. f is a maximum flow in G. 2. The residual network G f contains no augmenting paths. Proof. (1) (2): Obvious, because the existence of augmenting paths means a better flow exists. (2) (1): G f has no path from s to t. Let S be all the vertices that can be reached from s, and T = V S. Then (S,T) is a cut. For each u S and v T, f(u, v) = c(u, v). Therefore, f(s,t) = c(s, T). But we know that f (S,T) c(s, T) for any flow f. Hence we conclude that f is the maximum. Exercise: Read the proof of Theorem 26.6 at p.723 of the textbook. The proof there is essentially the same but in a different form. Corollary 1. The Ford-Fulkerson algorithm gives the maximum flow of a flow network. 19

Complexity Assuming that the capacities are integers. Every augmenting path will increase the flow by at least 1. So, the while loop will be repeated O( f ) time, where f is the maximum flow. The time complexity is O( E f ). Figure 26.7 on p.728 of textbook shows a worst case example. 20

Edmonds-Karp algorithm The Edmonds-Karp algorithm is almost the same as the Ford-Fulkerson algorithm. The difference is that we find the shortest path (in terms of number of edges) from s to t in the residual graph, and use the shortest path as the augmenting path. The worst case running time is reduced to O( V E 2 ). Proof is omitted. See p.729 of text book if you are interested to know. 21

Applications The maximum-bipartite-matching problem. Example: m boys and n girls are attending a dance party. Some of them can be matched. Find a solution so that you have maximum number of matches. The multiple-source max-flow problem. Example: A supermarket has several vendors for the same merchandise. It wants to transport the maximum number of merchandise to the market through its own transportation network. The multiple-sink max-flow problem. Example: A factory wants to send the maximum number of products to several countries through its own transportation network. The multiple-source multiple-sink max-flow problem. Maximum bipartite matching. Many other applications. 22