Definitions:
A flow network: directed graph G(V,E) with positive capacities
associated with its edges
c(v,u) => 0, for all (v,u) in E, and two special nodes source s in
V and sink, t in V.
We will assume that the source has only outgoing edges and the sink has
only incoming edges.
A flow: Given a flow network, a flow is a mapping of F: VxV ->
Real+
(each edge is assigned non-negative value) such that 0 <= F(u,v)
<= c(u,v)
(the flow of each edge is not greater than its capacity)
Notation: if there is no flow or no edge between two nodes u,v we
can say F(u,v) =0.
A legitimate flow: A flow is legitimate, if the following things hold:
1. Capacity rule:
0 <= F(u,v) <= c(u,v)
2.Conservation rule:
Sum_u F(u, v) = Sum_w F(v, w) , for all v
in V-{s, t}
(i.e. in flow = out flow except for source and sink or esle what
goes in must come out)
Value of a flow: We define
the value |F| of the flow F to be equal to the total flow
leaving the source, which we can
prove is equal to the total flow arriving at the sink.
|F| = Sum_w F(s, w) = Sum_w F(w, s)
Another approach:
The flow we define above is often called the net flow and it
is always positive.
Some textbooks (like the Big White) use a generalized definition
where flow f can be negative.
This small f flow refers to the total exchange of flow between
nodes and relates to the net flow
as follows:
f(u,v) = F(u,v) - F(v,u)
(Equation 1)
Consider the case where I have: u -> v
cap = 5 and net flow F(u,v) = 3
and: v-> u cap = 3 and net flow F(v,u) = 1
The flow f(u,v) = 2 and
the flow f(v,u) = -2
In other words f(u,v) expresses what is the total
amount of flow that is exchanged between nodes u and v.
Using Equation 1, we can switch between the two definitions.
For the rest of our discussion, we will assume the net flow.
The Maximum Flow:
A question of interest is what is the maximum flow I can push
from the source sto
the sink t.
Residual Capacity. Let us first look at the simpler problem
of the maximum flow I can push between two
nodes u, v assuming that I already have some flow F going
on.
We will call this flow residual capacity for these two nodes.
A. Assume that only the edge u -> v exists.
The maximum flow I can push from u to v is:
c_f(u,v) = c(u,v) - F(u,v)
/// Additional flow I can push on directed edge u -> v
B. Assume that only the edge u <- v exists. How much
flow can I push from u to v? I can stop receiving u flows,
which is equivalent to sending flow
to u. Therefore:
c_f(u, v) = F(v, u)
/// Amount of flow I can stop receiving from v = sending flow to v
C. Assume that both the edges u->v, and u<- v
exist. Then the residual capacity is from u to v is :
c_f(u,v) = c(u,v)
- F(u,v) + F(v, u)
(Equation 2)
and equivalently
for the residual capacity from v to u.
Residual Network. Given a flow network G(V,E) and a flow F, we
define the residual network G_f (V_f, E_f)
to be:
a. V_f = V (it has the same nodes
as the initial network)
b. Edges of (u,v)
in E_f have capacity according to Equation 2:
c_f(u,v) = c(u,v) - F(u,v) + F(v, u) > 0
Note that edges with zero capacity are considered as non existing.
Definition: Given a flow, an augmenting path
is a directed path from s to t such that we can push more flow
from s to t.
This corresponds to a path from s to t in
the residual graph (
Definition: Given an augmenting path,
we define as capacity of the augmenting path, F_p,
the minimum residual capacity of any
edge of the path (in the s to t direction of the path).
Intuition: if we add a legitimate
flow in the residual network to the existing flow, we get
a new legitimate flow.
Lemma (27.2 Big White)
Given a network G and a
flow F, if F' is a flow in the residual network G_f , then
the union of the flows F
and F' form a legitimate flow for network G.
Intuition, an
augmenting path shows a legitimate flow in the residual network.
Lemma (27.3 Big White)
Given an augmenting
path for a flow network G with flow F, the flow F_p (equal to the
capacity of the augmenting
path) is a legitimate flow.
Minimum Cut and Max Flow
Assume a cut S, T of G(V,E)
such that s in S and t in T. We will call this cut an st-cut.
Definition: Capacity of cut (S,T) is C(S,T) = Sum_x Sum_y c(x,y)
Definition: We define F(S,
T) = Sum_x Sum_y F(x, y) - Sum_x Sum_y F(y,x)
where x in S and y
in T
Properties of cuts. See Big White section 27.1, Lemma 27.1
In a flow netowrk, assume sets X, Y,Z subsets of V.
- F(X, X) = 0
- F(X,Y) = - F(X,Y)
- If X and Y do not
have commone elements X intersection Y = NULL,
F(X u Y, Z) = F(X, Z) + F(Y, Z),
where u is the union of two sets
- F(Z, X u Y)
= F(Z, X) + F(Z, Y)
The proofs are straighforward use of the definition.
Lemma - (Property 22.3
Red-green )
In a flow network
with flow F, the flow across each cut is equal to the flow F.
PROOF.
F(S,T) = F(S, V) - F(S,S) =
= F(S,V) =
= F(s, V) + F( S- {s}, V) =
= F(s, V) =
// By definition
= |F|
Note: F(
S- {s}, V) = 0 Why?
Hint: a set of nodes
that does not contain the source
can not be producing
positive flow to the rest of the network.
QED
Lemma - (Corollary
27.6 BWHITE,
In a flow network,
the value of its flow is bounded above by the capacity of any cut of G.
PROOF. For any
cut (S,T),
|F| = Sum_x
Sum_y F(x, y) - Sum_x Sum_y F(y,x) <= Sum_x Sum_y
F(x, y) <=
<= Sum_x
Sum_y c(x, y)
QED
Min-Cut Max-Flow Theorem.
The Maxmimum Flow of a flow network G(V,E) and source s and sink
t,
is equal to minimum
capacity of among all st-cuts.
For proofs and more details consult the textbooks.
1. Intialize flows to zero.
2. While there is an augmenting path
3. do augment flow as much
as legally possible
More detailed description on selecting paths.
Approach 1: (not the Ford-Fulkerson but
equivalent)
We can solve a max-flow problem executing the abstract algorithm
in the initial network G(V,E).
An augmenting path is a path that consists of edges
a) ...u -> v... (along the direction we traverse
the path)
and c(u,v) - f(u, v) > 0, and
the residual capacity c_f(u,v) = c(u,v) - f(u, v)
is the amount
that we can increase the flow on that edge.
b) ...u <- v .... (on the opposite from the direction we traverse
the path)
and there is non zero flow F(v,u) i.e. opposite to the direction
we
traverse the edge.
Having found the path, I push the maximum flow I can, which is the minimum of all the residual flows I can find.
Approach 2: (The Ford Fulkerson approach)
We can solve the max-flow problem using the residual graph G_f.
Intuitively, the idea of G_f, is a graph that has only one number
per edge to simplify
our searching for an augmenting path.
Attention 1: in the residual graph, we allow only positive net flows.
Attention 2: E_f may have more edges than E!!!!!!
Example: consider edge : u ----> v
with capacity 15 and zero flow initially.
When I route flow say of 5 untis, my edge becomes:
u----->v 5/15
In the residual graph, this corresponds to two edges with residual
capacities:
u -----> v 10 = 15 -5
u <----- v 5 = 0- (-5)
0 is the capacity the edge u<---v in G, since
in G it does not exist
-5 is the flow of the edge u<---v in G (recall
the skew symmetry constraint)
Intuitvely, u<---v with residual capacity 5, means that: now
u sends 5 units to v, so if I stop sending them, it is as if I send 5 units
from v to u and the two sets of units cancel each other.
In finding an augmenting path in G_f, I look for paths in G_f with edges in the direction that I am traversing them i. I.e. I only have edges
s ---> ...... ---> u -----> v ---> .... ---->
t
10
or
s ---> ...... ---> v -----> u ---> .... ---->
t
5
The Edmonds Karp Algorithm
Edmonds and Karp proposed a way to select among the multiple augmenting
paths.
This way, we can guarantee that the complexity of the algorithm
is O(V E).
* Initialize the network with zero flow
* Repeat until you can't find an augmenting path
-- Find a minimum-hop augmenting path
-- Push the maximum flow on that path