Maximum Flow Problems: Flows and Cuts Augmenting Path Algorithm

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 15

Chapter 6

Maximum Flow Problems


Flows and Cuts
Augmenting Path Algorithm
Definitions/Assumptions

Each arc (i, j) has an arc capacity uij. U  max


i , j A
uij : uij  
The problem is to find the maximum flow from the source
node, s, to the sink node, t.
Assumptions:
The network is directed
All capacities are nonnegative integers
There is no directed path from s to t composed only of
infinite capacity arcs
Each arc (i, j) has a corresponding reverse arc (j, i) (could
have 0 capacity)
There are no parallel arcs

2
Residual Network (see pp. 44-46)

Given a set of flows x = {xij}, the residual network tells what


changes are feasible. For each arc (i, j), G(x) contains:
A forward arc with residual capacity rij = uij – xij (if > 0)
A backward arc with capacity rij = xij (if > 0)
The residual capacity of an s-t cut is the sum of the residual
capacities of forward arcs in the cut.
Facts:
The value of any flow is less than or equal to the capacity
of any s-t cut in the network.
The additional flow that can be sent from s to t is no greater
than the residual capacity of any s-t cut.
3
Generic Augmenting Path Algorithm

algorithm augmenting path;


begin
x := 0;
while G(x) contains a directed path from node s to node t
do
begin
Identify an augmenting path P from node s to node t;
  rij :  i, j   P ;
augment  units of flow along P and update G(x);
end;
end;
4
Augmenting Paths

• An augmenting path is a directed path from the source to the sink in the
residual network
– Its capacity is the minimum (residual) capacity of the arcs it contains
– If the network contains an augmenting path, then we can send more units
of flow from the source to the sink
• An increase of  units on arc (i, j) in the residual network corresponds
to, in the original network, increasing xij by  units, or decreasing xji by
 units, or increasing xij by a units while decreasing xji by (1-a) units,
0 < a < 1 (i.e., an aug. path may actually subtract flows from some arcs)
• Residual capacities do not uniquely determine the flows in the original
network. We will use the convention:
– if uij  rij, set xij = uij - rij and xji = 0
– otherwise, set xij = 0 and xji = rij - uij

5
Labeling Algorithm

Q. How to find an augmenting path?


A. Use the search algorithm (from Chapter 3) to find nodes
reachable from the source node in the residual network.
If the sink is reachable then a path from the source can
be traced backward using predecessor indices.
B. If the search procedure fails to label the sink node as
reachable, then it will have identified an s-t cut in the
residual network with rij = 0 for each arc (i, j) in the cut.
Therefore, xij = uij for each arc in the cut, and the total
flow from s to t equals the capacity of this cut.

6
The Labeling Algorithm (main)

7
Procedure augment

8
Max-Flow Min-Cut Theorem

Since the labeling algorithm stops when it identifies an s-t cut


whose capacity equals the flow from s to t,
and since the capacity of any s-t cut is an upper bound on the
total value of any feasible flow, it follows that
(Max-Flow Min-Cut Theorem) The maximum value of the
flow from a source node s to a sink node t in a capacitated
network equals the minimum capacity among all s-t cuts.
Also,
A flow is a maximum flow if and only if the corresponding residual
network contains no augmenting path, and
If all arc capacities are integer, the maximum flow problem has an
integer maximum flow.
9
Ch. 7: Distance Labels
In maximum flow problems, measure the distance of a node
from the sink node as the smallest number of arcs on any
directed path from this node to the sink.
2

1 4
3
t = 4: d(1) = 3, d(2) = 1, d(3) = 2, d(4) = 0
The shortest augmenting path algorithm identifies the
augmenting path in the residual network containing the
fewest arcs and runs in O(n2m) time (labeling algorithm is
O(nmU), where U is the largest finite arc capacity).
10
Preflow-Push Algorithm

• Augmenting path algorithms can take excessive time by


repeatedly sending flows down the same subpaths (see
Fig.7.10). Sending a flow along a path takes O(n) time in
the worst case.
• Note that augmenting path algorithms always maintain a
feasible flow (satisfies capacity and flow conservation
constraints).
• The preflow-push algorithm always obeys capacity
constraints but does not satisfy the conservation
constraints until it reaches the optimal solution.
– A preflow is a set of arc flows in which the total flow into a node
may exceed the total flow out of the node;
– A push is the simple operation of sending flow down a single arc.
11
Excesses

Given a flow x, the excess of each node i is given by


e i    x ji   xij
 j: j ,i A  j:i , j A
In a preflow, e(i)  0 for each i  s. Node s is the only node
with a negative excess (because no arcs are directed into
it). Nodes i  t with e(i) > 0 are called active.
Active nodes indicate infeasibility; the algorithm moves
toward feasibility by trying to push the excess flow to the
active node’s neighbors; in particular, to nodes closer to
the sink (measured by “distance”).
An admissible arc is an arc (i, j) for which d(i) = d(j) + 1.
12
Preflow-Push Subroutines

procedure preprocess;
begin
x := 0;
compute the exact distance labels d(i);
xsj = usj for each arc (s, j)  A(s);
d(s) := n;
end;

procedure push/relabel(i);
begin
if the network contains an admissible arc (i, j) then
push  = min{e(i), rij} units of flow from i to j
else replace d(i) by min{d(j) + 1 : (i, j)  A(i) and rij > 0};
end;
13
Preflow-Push Algorithm

algorithm preflow-push;
begin
preprocess;
while the network contains an active node do
begin
select an active node i;
push/relabel(i);
end;
end;

14
Termination & Complexity

The preflow-push algorithm stops when all the excess is


collected at the source or the sink, i.e., the current preflow
is a feasible flow. The excess at the sink is the maximum
flow value.
This generic version runs in O(n2m) time. Depending on how
the list of active nodes is maintained, variations of it run in
O(n3), O(n2m1/2), or O(nm + n2 log U) time, which may be
smaller depending on the instance.

15

You might also like