0% found this document useful (0 votes)
2 views6 pages

Lecture 16

The document discusses the max flow and min cut problems in directed graphs, detailing their historical context, mathematical formulation, and the max flow-min cut theorem. It explains the constraints for defining flow and cut, provides examples, and outlines an algorithm to determine maximum flow and minimum cut in a graph. The document concludes with proofs demonstrating the relationship between max flow and min cut, emphasizing that the value of the max flow equals the cost of the min cut.

Uploaded by

3278572433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Lecture 16

The document discusses the max flow and min cut problems in directed graphs, detailing their historical context, mathematical formulation, and the max flow-min cut theorem. It explains the constraints for defining flow and cut, provides examples, and outlines an algorithm to determine maximum flow and minimum cut in a graph. The document concludes with proofs demonstrating the relationship between max flow and min cut, emphasizing that the value of the max flow equals the cost of the min cut.

Uploaded by

3278572433
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

CS161 Max Flow, Min Cut

Scribe: Chuanqi Shen (2015), Virginia Date: May 27, 2016

1 History of Flows and Cuts


Today we will continue the theme of studying cuts in graphs. In particular we will be studying a very
interesting problem called the max flow problem. Before that, a short history lesson. During the Cold
War, the US Air Force at that time was very interested in the Soviet train networks. In reports that were
declassified in 1999, it was revealed that the Air Force collected enough information about the train network
that they were able to determine how resources were shipped from the Soviet Union to Europe. The Air
Force was very interested in determining how much resources can be transported from the Soviet Union to
Europe, and what needed to be done to destroy this movement of resources. What this translates to is the
min cut problem i.e. cut the minimum number of train tracks so that nothing goes to Europe. Here, cutting
an edge means dropping a bomb. Nowadays however, there are much milder applications of this problem,
for instance, understanding the flow of information through the Internet.

2 Formulation of max flow


You are given an input graph G = (V, E), where the edges are directed. There is a function c : E → R+
that defines the capacity of each edge. We also label two nodes, s and t in G, as the source and destination
respectively. The task is to output a flow of maximum value. We will shortly define what a flow is and what
a flow of maximum value means.
A flow f is a function f : E → R+
0 such that

1. (Capacity Constraint)
∀(u, v) ∈ E, 0 ≤ f (u, v) ≤ c(u, v)
.
2. (Flow Conservation Constraint)
X X
∀v ∈ V \{s, t}, f (x, v) = f (v, y)
x∈Nin (v) y∈Nout (v)

Here Nin (v) denotes the set of nodes with an edge that points to v and Nout (v) denotes the set of
nodes that v points to.

Suppose that P there are no edges going


P into s and no edges coming out of P t, From the above, you can verify
yourself that x∈Nout (s) f (s, x) = y∈Nin (t) f (y, t). We define the value x∈Nout (s) f (s, x) to be the value
of the flow f . We usually denote the value of a flow f as |f |. If there are edges into s and out of t, then the
value of f is X X
|f | = f (s, x) − f (y, s).
x∈Nout (s) y∈Nin (s)

The max flow problem is to find some flow f such that |f | is maximized.

1
5 5
a b a b
10 100 5 6

3 1
s 12 t s 0 t
11 10 11 10

c c

Figure 1: (Left) Graph G with edge capacities (Right) Graph G with a sample flow

3 Example
In Figure 1, we have a graph G and a sample flow f . Observe that the two constraints for a flow are satisfied.
There can be multiple other flows possible that can satisfy the constraints. For our given flow, |f | = 16. The
max flow for this graph is actually 18, as we will see shortly.
Here in this case, there is no edge into s. However, when there can be edges into s, we can define |f | more
generally as X X
|f | = f (s, x) − f (y, s)
x∈Nout y∈Nin (s)

4 Formulation of min cut


Now, we give a formulation of min cut. We have previously introduced min cuts, but we will now introduce
another definition of min cut defined for directed graphs in terms of source and destination nodes s and t.
S
An s − t cut is a partition V = S T where S and T are disjoint and s ∈ S, t ∈ T , and the size/cost of an
s − t cut is X
kS, T k = c(x, y)
x∈S,y∈T

For our graph G shown above, if we set S = {s, a, c} and T = {b, t}, then the cost of the cut is c(a, b) +
c(c, b) + c(c, t) = 5 + 3 + 10 = 18. If we take another cut S 0 = {s, c}, T 0 = {a, b, t}, then kS 0 , T 0 k =
c(s, a) + c(c, b) + c(c, t) = 10 + 3 + 10 = 23. Note that we do not consider the edge {a, c} as it is in the
wrong direction (we only consider edges from S 0 to T 0 ).

5 The max flow min cut theorem


Lemma 5.1. For any flow f and any s − t cut (S, T ) of G, we have |f | ≤ kS, T k. In particular, the value
of the max flow is at most the value of the min cut.

2
Proof.
X X
|f | = f (s, x) − f (y, s)
x∈Nout (s) y∈Nin (s)
 
X X X
=  f (v, x) − f (y, v) by the Flow Conservation Constraint all added terms sum to 0
v∈S x∈Nout (v) y∈Nin (v)
   
X X X X X X
=  f (v, x) − f (y, v) +  f (v, x) − f (y, v)
v∈S x∈Nout (v)∩S y∈Nin (v)∩S v∈S x∈Nout (v)∩T y∈Nin (v)∩T

 
X X X
=  f (v, x) − f (y, v) first term sum to 0 because everything cancels out
v∈S x∈Nout (v)∩T y∈Nin (v)∩T
X X
≤ f (v, x) ≤ c(v, x) = kS, T k
v∈S,x∈T,x∈Nout (v) v∈S,x∈T,x∈Nout (v)

We get the following consequence.


Corollary 5.1. If we can find f and (S, T ) such that |f | = kS, T k, then f is a max flow and (S, T ) is a min
cut.

It turns out that we can always find such f and (S, T ) for any graph.
Theorem 5.1 (Max flow-Min cut theorem). For any graph G, source s and destination t, the value of the
max flow is equal to the cost of the min cut.

We will show this by coming up with an algorithm. The algorithm will take the graph G and some flow f
that has already been constructed, and create a new graph that is called the residual graph. In this new
graph, the algorithm will try to find a path from s to t. If no such path exists, we will show that the value
of the flow we started with is maximum. If not, we show how to increase the value of our flow by pushing
some flow on that path.

6 Algorithm
We will make an assumption on our graph. The assumption can be removed, but it will make our lives
easier. We will assume that for all u, v ∈ V , G does not have both (u, v) and (v, u) ∈ E(G). We can make
this condition hold by modifying the original graph. If (u, v), (v, u) ∈ E(G), we split the edge (u, v) to two
edges (u, x) and (x, v), where x is a new node we introduce into the graph. This makes the number of nodes
at most m + n.
Now, let f be a flow given to us. We will try to see if we can improve this flow. We will define the residual
capacity cf : V × V → R+ 0 as follows.
 
 c(u, v) − f (u, v) if (u, v) ∈ E(G) 
cf (u, v) = f (v, u) if (v, u) ∈ E(G)
0 otherwise
 

3
a b
5 5 94
5
s 6
12 t
2
1
11 c 10

Figure 2: residual network

Basically, what this does is that, if there is any flow through the edge, you remove the flow from the capacity
and add an edge in the opposite direction with the value of the flow. The reason we do this is because the
flow we picked thus far might not be the correct flow, and this formulation allows us to undo changes that
we have done.
We define Gf to be a residual network defined with respect to f , where V (Gf ) = V (G) and (u, v) ∈ E(Gf )
if cf (u, v) > 0. Figure 2 shows G with the residual edges.
We will show that, if there is a path from s to t in Gf , then f is not a max flow. If no such path exists, that
f is max flow.

Lemma 6.1. If t is not reachable from s is Gf , then f is a maximum flow.

Proof. Let S be the set of nodes reachable from s in Gf and T = V \S. There are no edges in Gf from S to
T since t is not reachable from s. Note that (S, T ) defines an s − t cut. Now consider any v ∈ S, w ∈ T . We
have cf (v, w) = 0 since (v, w) is not an edge in Gf . There are three cases

1. If (v, w) ∈ E, then by definition cf (v, w) = c(v, w) − f (v, w) = 0 =⇒ c(v, w) = f (v, w).

2. If (w, v) ∈ E, then cf (v, w) = f (w, v) = 0.


3. If (v, w) ∈
/ E, (w, v) ∈
/ E, then we can disregard (v, w) and (w, v) since they do not appear in any flow
or cut.

Using this, and the proof in Lemma 5.1, we have


 
X X X
|f | =  f (v, x) − f (y, v)
v∈S x∈Nout (v)∩T y∈Nin (v)∩T
X X
= f (v, x) (because from case 2 the second term above is 0)
v∈S x∈Nout (v)∩T
X X
= c(v, x) (from case 1)
v∈S x∈Nout (v)∩T

= kS, T k

Thus, we show that the flow is equal to the cut. From Corollary 5.1 we know that f is a maximum flow,
and kS, T k is a min cut. 
Lemma 6.2. If Gf has a path from s to t, we can modify f to f 0 such that |f | < |f 0 |.

4
Proof. Pick a path P from s to t in Gf , and consider the edge of minimum capacity on the path. Let that
capacity be v. Then we can increase our flow by v. For each edge in P , if cf (v, w) is the right direction
(i.e there is an edge (v, w) ∈ E(G)), then we can increase our flow on this edge by v. If cf (v, w) is in the
opposite direction (i.e. (w, v) ∈ E(G)), then we can decrease the flow on this edge by v. In effect, we are
”undoing” the flow on this edge. By doing so, we have increased our flow by v.
As an example, Figure 2 again. The path s → a → c → b → t is a path with minimum capacity 2. Therefore,
we can update our flow and push an additional 2 units of flow, resulting in a flow of 18.
Formally, Let s = x0 → x1 → ... → xk = t be a path P in Gf , and let F = mini cf (xi , xi+1 ). Define a new
flow f 0 where  
 f (u, v) + F if (u, v) ∈ P 
f 0 (u, v) = f (u, v) − F if (v, u) ∈ P
f (u, v) otherwise
 

We now need to show that f 0 is a flow. The capacity constraints are satisfied because

1. If (u, v) ∈ P , then 0 ≤ f (u, v) + F ≤ f (u, v) + cf (u, v) = f (u, v) + c(u, v) − f (u, v) = c(u, v)


2. If (v, u) ∈ P , then f (u, v) − F ≤ f (u, v) ≤ c(u, v) and f (u, v) − F ≥ f (u, v) − cf (u, v) = 0.
3. Otherwise, f (u, v) is from the original flow f .

The conservation constraints are also satisfied: Suppose that P is simple. Thus, for every v ∈ V , P uses 0
or two edges incident on v. If P uses 0 edges on v, then the edge flow values incident on v have not changed
when going from f to f 0 . Thus, suppose that P uses two edges (x, v) and (v, y) incident on v. Because in
Gf some edges appear in the opposite direction compared to G, we need to consider a few cases.

1. (x, v) and (v, y) are both in the same direction (an edge into v and an edge out of v); the flow into v
increases by F and the flow out of it also increases by F
2. (x, v) and (v, y) are both in the opposite direction (an edge opposite to one into v and an edge opposite
to one out of v); the flow into v decreases by F and the flow out of it also decreases by F
3. (x, v) is in the correct direction and (v, y) is in the opposite direction. Then the flow into V changes
by F − F = 0.
3. (x, v) is in the opposite direction and (v, y) is in the correct direction. Then the flow out of V changes
by F − F = 0.

Finally, |f 0 | > |f | because we just increase our flow by F , and by our definition of Gf , it must be that F > 0.


From this, we can construct an algorithm to find the maximum flow. Starting with some arbitrary flow of
the graph, construct the residual network, and check if there is a path from s to t. If yes, update the flow,
construct the new residual graph and repeat. Otherwise, we have found the max flow.
A path from s to t in the residual graph is called an augmenting path, and pushing flow through it to modify
the current flow is referred to as augmenting along the path.
Here is the max flow algorithm attributed to Ford-Fulkerson.
The runtime of this algorithm is bounded by the number of times we update our flow. If edge capacities are
all integers, then we can increase the flow by at least 1 each time we update our flow. Therefore, the runtime
if O(|f |m) where |f | is the value of the max flow. If we have rational edge capacities, then we can multiply
all edge capacities by a factor to make them all integers. However, the runtime blows up by a factor as well.

5
Algorithm 1: maxflow(G, s, t)
f ← all zeroes flow;
Gf ← G;
while t is reachable from s in Gf (check using DFS) do
P ← path in Gf from s to t;
F ←min capacity on P ;
f ← f 0 as defined in Lemma 6.2;
return f ;

If we have irrational edge capacities, then the algorithm is no longer guaranteed to terminate. So we have a
problem.
We will save the day in the next lecture.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy