METHODS FOR SOLVING MAXIMUM FLOW PROBLEM ARBA MINCH UNIVERSITY
COLLEGE OF NATURAL SCIENCE DEPARTMENT OF MATHEMATICS
Prepared by : Geleta Tadele Mohammed September 10, 2015
Abstract This project (seminar) paper deals with Maximum flow minimum cut problem. And it contains two major ideas. These two ideas are how to solve the given maximum flow problem by using Ford Fulkerson Algorithm and by using minimum cut maximum flow method. And also it contains three chapters, the first two chapter’s deals with the preliminary and Ford Fulkerson Algorithm, the final chapter deal with the minimum cut maximum flow method respectively Keywords: Maximum flow problem; Flow augmenting path; Ford-Fulkerson labeling algorithm; Max-flow Min-cut Theorem.
Contents Acknowledgement
1
1 Introduction To Maximum Flow Problem
2
2 Flow Augmenting Path method And Ford-Fulkerson Labeling Algorithm 5 2.1 Flow Augmenting Path (FAP) Method . . . . . . . . . . . . . 5 2.2 Ford-Fulkerson Labeling Algorithm . . . . . . . . . . . . . . . 7 3 Max-Flow Min-Cut Theorem
11
Bibliography
18
Acknowledgement I would like to express my true adore by saying ”I love you my GOD” to my creature at all. This is all about acknowledgement I have .
1
Chapter 1 Introduction To Maximum Flow Problem Definition 1.1. [2] • A graph G = (V, E) consists a none empty finite set V of vertices and finite set E of edges, where each edges links a vertex to a vertex. • If e is an edge connecting vertex u to v, we write e = (u, v). In this case we say that e is incident with u(and v) , and u is adjacent to v. • Two edges are said to be adjacent if they are incident with common vertex. • Loop is an edge connecting a vertex to itself. • parallel edges are two or more edges incident with same two vertices. • Simple graph is a graph that contains no parallel edges and also no loop.a graph which is not simple is called Multiple graph. But any multiple graph can be transformed to a simple graph by transforming loops to parallel edge using artificial vertex , and parallel edges to none parallel edges by using artificial vertex and dividing edges. Thus, we cam consider only simple graphs for discussion. • A path from v1 to vt ( of between v1 and vt ) in a graph G is the sequence of adjacent edges (v1 ,v1 ) , (v2 , v3 ) ,...,(vt−1 ,vt ) where no edge and also no intermediate vertex is repeated. It is denoted by v1 -v2 -. . .- vt . • A graph G = (V, E) is said to be a Weighted graph (Network) if each its edge e is assigned a number w(e), called weight of e. • A directed edge is called Arc. • A graph G = (V, E) is said to be a digraph(directed graph) if each of its edge are directed edge. If the graph is directed graph , the replace E by A. • A graph is said to be connected if there is a path between every pair of its vertices.
2
Each arc has the upper bound or the arc flow known as the arc capacity. An example of the graph with nodes, arcs and arc capacity is following:
Fig:1 The above figure has 4 nodes and 4 arcs. In the above graph, the source is node A and the sink is Node D. The arc between A and B has arc capacity of 4 and the arc between A and C has the arc capacity of 5. Similarly, the arc capacity of (B, D) and (C, D) is 3 and 7 respectively. Each arc has restricted upper bound such that the capacity cannot be more than the given flow in each arc. In the graph, we have a path from A to C to D.A path from as vertex v to vertex u is an alternating sequence of vertices and edges which starts with v and ends with u. Let G = (V, A) be a capacitated connected digraph with a non-negative capacity ui,j for each arc (i, j) ∈ A. We distinguish two nodes s, t ∈ V , calledsource and sink nodes , respectively, with assumption that the flow is originated from s and destined to t . All other nodes are called intermidiate vertices. Given a capacitated network with source s and sink t , a flow vector x ∈ R|A| is said to be feasible in G = (V, A) if each of its component satisfies capacity constraint and for any value v > 0,
X j∈N A(i)
xij −
X j∈N B(i)
xji
v = o −v
if i = s if i = 6 s, t and i ∈ V if i = t
3
(f low conservation equation)
The value of flow is v=
X
xsj
j∈N A(s)
. Here ,N A(i) and N B(i) are the set of all nodes after i and the set all nodes before i respectively. We assume that the source nodes s can provide unlimited amount of flow and the sink node t can receive unlimited amount of flow. The value problem is now the problem of finding the maximum flow from s to t in G = (V, A) that satisfies the flow conservation equation and capacity constraint. i.e if i = s v X X M ax v = xij − xji = o if i 6= s, t and i ∈ V (f low conservation equation) j∈N A(i) j∈N B(i) −v if i = t S.t
0 ≤ xij ≤ uij f or all (i, j) ∈ A
which is a capacity constraint.
4
Chapter 2 Flow Augmenting Path method And Ford-Fulkerson Labeling Algorithm 2.1
Flow Augmenting Path (FAP) Method
Intuitively , Flow Augmenting Path is a path from s to t along which we can send more flow than is currently in the network. For any s − t path p , let • P + := set of all f orward arcs on p • P − := set of all backward arc on P Definition 2.1. [2] A path P from s to t is an F AP if and only if (i) . xij < uij ∀(i, j) ∈ p+ (ii) . xij > 0 ∀(i, j) ∈ p− To determine a maximum flow through a F AP , P , let 41 = min{uij − xij |(i, j) ∈ p+ } 42 = min{xij |(i, j) ∈ p− }. Then 4 = min{41 , 42 } is called residual capacity of P , is the maximum flow that can be send through path p . Hence, the new flow in the network is : + xij + 4 , if (i, j) ∈ p xij = xij − 4 , if (i, j) ∈ p− xij else 5
and this is called flow augmentation Example 2.1. [2] Consider the following capacitated 1 − 6 network with given flow. By using an F AP and its residual capacity find the maximum flow.
F ig.6 Solution: Flow augmenting path (F AP ) : P = 1-3-5-2-4-6. then P + = { (1,3),(3,5), (2,4), (4,6)} P − = { (2,5)} 41 = min{8 − 3 , 4 − 0, 8 − 4 , 9 − 7} = min{5, , 4, 4, 2} = 2 42 = min{5} = 5 ⇒ 4 = min{41 42 } = min{2, 5} = 2. Then,flow augmentation along the flow augmenting path (FAP) gives: x12 = 3 + 2 = 5 ,x35 = 0 + 2 = 2 ,x25 = 5‘ − 2 = 3 , x24 = 4 + 2 = 6 ,x46 = 7 + 2 = 9 . After this flow of augmentation , the flow in the network is :
F ig.7 Since we can’t find any more F AP in the network now, then the current flow is maximum with flow value v = 14 = 9 + 5. 6
Since getting a flow augmenting path F AP from a given network is not easy, let say something about Ford- Fulkerson labeling algorithm which is useful to determine F AP of the given network.
2.2
Ford-Fulkerson Labeling Algorithm
This algorithm starts with a feasible flow(say xij = 0 f or all arcs) , identifies F AP and does a flow augmentation iteratively until no more augmenting path can be constructed. To identify a flow augmenting path, this algorithm puts label on each node j which indicates the node prior to node j on the current flow augmenting path . If j is labeled by (+, i) and jis labeled by (-, i), then it is to mean that (i, j) ∈ P + and (i, j) ∈ P − , respectively. This algorithm starts from s and puts stepwise such labels on nodes and eventually when t is labeled we can get the flow augmenting path by following the labels starting at t and back to s . i.e, we can get the F AP by backtracking using the labels. After an F AP , say P , is identified, then this algorithm determine the residual capacity 4 of P and perform flow augmentation. If a node j on P has label (+, i) , and (−, i) , then xij = xij + 4 and xij = xij − 4 ,respectively. At each iteration of this algorithm every vertex(node) of the network is in one of the following states : 1. Labeled and Scanned (listed in set S1 ) 2. Labeled but not Scanned (listed in set S2 ) 3. Unlabeled and (listed in set S3 ) The inputs we need in this algorithm are : • Capacitated network G = (V, A) where V = {1, 2, 3, ..., n} • Source node 1 and sink node n • Initial feasible flow : possibly xij = 0 ∀ (i, j) ∈ A Ford-Fulkerson labeling algorithm It is to find maximum flow from vertex 1 to n. (1). Initial :Let S1 : = ∅ ; S2 : = {1} ; S3 : = {2, 3, ..., n} (2). Scanning :
7
Choose i ∈ S2 , Put S1 : = S1
S
{i} ; S2 : = S2 \ {i} (i is scanned)
(3). Labeling : T ∀ j ∈ N A(i) S3 do: If xij < uij , then · Label j with (+,i); S · S2 : = S2 {j} ; S3 : = S3 \ {j} If j = n , identify F AP by backtracking ; find its 4 , do flow augmentation, and remove all labels and go to step (1) T (3.2) ∀ j ∈ N B(i) S3 do : if xij > 0 ,then
(3.1)
. Label j with (-,i) ; S . S2 : = S2 {j} ; S3 : = S3 \ {j}; (4). If S2 6= ∅ , go to Step(2); else , i.e, if S2 = ∅ , the current flow is maximum , STOP. Example 2.2. By using Ford-Fulkerson Labeling algorithm find the maximum flow of the following network from vertex 1 to 6.
F ig.1 Solution: Initial: S1 := ∅ , S2 : = {1} ; S3 : = {2, 3, 4, 5 , 6} Iteration 1 Scanning: Choose 1 ∈ S2 , Put S1 : = S1
S
{i} ; S2 : = S2 \ {i} (i is scanned) 8
T Labeling : Since N A(1) = {2, 3} , S3 = {2, 3, 4, 5, 6} , N A(1) S3 = {2, 3} and T the f low x , x are zero then label 2 and 3 by (+,1).Because 13 T 12 of N B(1 ) S3 = ∅ , then goto step (4). since S2 = {2, 3} 6= ∅ , then goto step (1).i.e, Iteration 2 T Choose 2 ∈ S2 , then S1 := {1, 2},S2 := {3} since N A(2) S3 = {4, 5} and x24 , x25 are zero , then label T 4 and 5Tby (+,2) and put S2 : = {3, 4, 5} , S3 : = {6}. Since N B(2 ) S3 = ∅ , then go to step(4). since S2 = {3, 4 , 5} = 6 ∅ , then go to step(1). i.e Choose 4 ∈ S2 , then S1 := {1, 2, 4},S2 := {3, 5} since Iteration 3 T N A(4) S3 = {6} and x46 is zero , then label 6 by (+,4) and put S1 : = {1, 2, 4, 6} , S3 : = ∅. since n= 6, then by backtracking we get F AP P1 : 1 − 2 − 4 − 6 with 4 = 7. Then after doing flow augmentation to this F AP we get
F ig.2 by using similar procedure as given above we get F AP P2 : 1 − 3 − 4 − 6 with 4 =4 F AP P3 : 1 − 3 − 4 − 2 − 5 − 6 with 4 = 5. and the final network is :
F ig.3 9
with maximum flow v = 7 + 9 = 16 or v = 5 + 11 = 16
10
Chapter 3 Max-Flow Min-Cut Theorem Let G = (V, A) be a network (directed graph with no parallel edges) Definition 3.1. [?] Suppose V is partitioned into two non-empty sets A and B = V \A , wheres ∈ A and t ∈ B. An s − t cut , denoted by [A|B] , is the set of all arcs whose end points belongs to the different subsets A and B. Definition 3.2. PThe capacity of an s − t cut [A|B] , Cap[A|B] : = (i,j)∈(A,B) uij (the sum of capacities of forward arcs in the cut) Definition 3.3. (i). (A,B): = {(i, j) ∈ [A|B] | i ∈ A, j ∈ B} the set of forward arcs in the cut. (ii). (B,A): = {(i, j) ∈ [A|B] | i ∈ B, j ∈ A} the set of backward arcs in the cut. S clearly , for any S − t cut [A|B] =(A,B) (B,A).
11
Example 3.1.
F ig.4
F ig.9 12
Minimum s − t Cut Problem Among all s − t cuts in a network ,a cut with the minimum capacity is called minimal cut (s − t cut having minimum capacity). Definition 3.4. An s − t flow is a function that satisfies: (i) ∀e ∈ A , 0 ≤ f (e) ≤ c(e) (capacity constraint) (ii) ∀v ∈ V \ {s, t} ,
X
X
f (e) =
e into v
f (e)
(conservation constraint)
e out of v
Definition 3.5. The Value of a flow is X V (f ) :=
f (e)
e out of s
Example 3.2.
F ig.10 Note: A network is a directed graph (digraph) G = (V, A) with a capacity function c : A → R assigning arcs to none negative real values. Flows as linear programs : X
M aximize V (f ) =
f (e)
e out of s
s.t X e into v
f (e) =
X
f (e)
e out of v
13
,
0 ≤ f (e) ≤ c(e)
F ig.8 Definition 3.6 (Net flow across a cut). Let [A|B] be any s − t cut . The net flow across a cut [A|B] is X X N [A|B] := f (e) − f (e) e out of A
e into A
Theorem 3.1 (Flow Value Lemma). Let f be any flow and [A|B] be any s − t cut , then the net flow across the cut is equal to the flow value. i.e X X N [A|B] = f (e) − f (e) e out of A
e into A
= V (f ). Proof. Let f be any flow in G and [A|B] be any s − t cut of G. by definition
14
of V (f ), we have that X
V (f ) =
f (e)
e out of s
X
=
X
f (e)
e into A
e out of s
+
X
f (e) − (
X
X
(
X
=
X
f (e) −
f (e))
e into v
v∈A e out of v
X
f (e))
e into v
v∈A\{s} e out of v
=
X
f (e) −
X
f (e) −
f (e)
e into A
e out of A
= N [A|B]
Analogously, we have the following Theorem. Theorem 3.2 (Weak Duality). Let [A|B] be any s − t cut . Then for any s − t cut [A|B] we have , V (f ) ≤ Cap[A|B]. Proof. Since by Flow Value lemma we have that,
V (f ) =
X
f (e) −
≤
f (e)
e into A
e out of A
X
X
f (e)
e out of A
≤
X
c(e)
(b/c of
f (e) is + ve)
e into A
e out of A
= Cap[A|B]
X
(by def inition of cut [A|B])
Theorem 3.3 (Optimality Certificate). Let f be any flow in G and [A|B] be any s − t cut of G.If the flow value is equal to the capacity of the cut , then the flow is maximum and [A|B] is minimal cut. Proof. Let f be any arbitrary flow in G and [A|B] be any arbitrary s − t cut of G. Given V (f ) = Cap[A|B] , W.T.S V (f ) is maximum and [A|B] is minimal 15
s − t of G. Since from Weak Duality theorem , we have that V (f ) ≤ Cap[A|B] for any s − t cut [A|B]. Then by definition of minimal cut and hypothesis we can sat that [A|B] is minimum cut. Because of Cap[A|B] =
X
c(e)
e out of A
and V (f ) ≤ Cap[A|B] for any s − t cut [A|B] , then V (f ) is maximum flow value. Theorem 3.4 (Max-Flow Min-Cut Theorem). Let f be any flow in G and [A|B] be any s − t cut in an s − t flow network G = (V, A) , then the following conditions are equivalent: (i) V (f ) is maximum flow in G (ii) There is no F Ap corresponding to V (f ) in G (iii) V (f ) = Cap[A|B] , for some s − t cut [A|B] (existence of s − t cut such thatV (f ) = Cap[A|B] ) Proof. (i) ⇒ (ii) To prove it by contrapositive , suppose that there is an augmenting path with respect to f . ⇒ we can improve flow f by sending floe along this path. Thus, f is not a maximum flow. (ii) ⇒ (iii) Suppose there is no F AP corresponding to V (f ). Let [A|B] be an s − t cut where A is the set of vertices connected to s by undirected path with no full forward or empty backward edges. By definition, S is in A ; since no augmenting path, t is in B .Capacity of an s − t cut [A|B] is Cap[A|B] = net f low across ← f orward edges f ull, = V alue of f low f = V (f ) (iii) ⇒ (i) Suppose that [A|B] is an s − t cut with V (f ) = Cap[A|B] . Then, the value of any f low f 0
≤ Cap[A|B] = value of f
Thus, f is a maximum flow. 16
(by weak dualityT hm.) (by assumption)
Here, the Max-flow Min-cut theorem means that we can determine the minimum cut value using the Ford and Fulkerson maximum flow algorithm. The minimum cut is actually simple to find after the Ford-Fulkerson algorithn has been completed. Simply mark the arcs that are carrying a flow equal to their maximum flow capacity and look for acut that consists only of marked arcs and has no other arcs. It often happens that not all of the marked arcs are used in the cut , and it may also happen that there are multiple cuts that can be made in this way. Computing a Min-Cut From a Max-flow : TO compute Min-cut [A|B] from max-flow f : • By augmenting path theorem, no augmenting paths with respect to f . • Compute A = set of vertices connected to s by an undirected path with no full forward or empty backward edges. Example 3.3.
F ig.11 Therefore , A= {5, 3, , 4, 7} Hence the min -cut is [A|B] where B = V \ A.
17
Bibliography [1] Tero Harju, “Lecture Notes on GRAPH THEORY”, Department of Mathematics University of Turku FIN-20014 Turku, Finland e-mail:
[email protected] 1994-2011 [2] Allen Dickson, “Introduction to Graph Theory”, October 2006. [3] Ford, L.R; Jr. and D.R.Fuikerson, “flow in networks Princeton, N.J.princeton University press 1992”, 1962. [4] Shaun Joseph, “The Max-Flow -Min-cut Theorem,December 6, 2007
18