15
Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

Embed Size (px)

Citation preview

Page 1: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

Chapter 6Maximum Flow Problems

Flows and Cuts

Augmenting Path Algorithm

Page 2: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

2

Definitions/Assumptions

Each arc (i, j) has an arc capacity uij.The problem is to find the maximum flow from the source

node, s, to the sink node, t.Assumptions:

The network is directedAll capacities are nonnegative integersThere is no directed path from s to t composed only of infinite capacity arcsEach arc (i, j) has a corresponding reverse arc (j, i) (could have 0 capacity)There are no parallel arcs

,max :ij iji j A

U u u

Page 3: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

3

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.

Page 4: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

4

Generic Augmenting Path Algorithm

algorithm augmenting path;begin

x := 0;while G(x) contains a directed path from node s to node t dobegin

Identify an augmenting path P from node s to node t;

augment units of flow along P and update G(x);end;

end;

: , ;ijr i j P

Page 5: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

5

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

Page 6: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

6

Labeling Algorithm

Q. How to find an augmenting path?

R. 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.

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.

Page 7: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

7

The Labeling Algorithm (main)

Page 8: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

8

Procedure augment

Page 9: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

9

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.

Page 10: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

10

Ch. 7: Distance LabelsIn 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.

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

1

3

2

4

Page 11: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

11

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.

Page 12: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

12

Excesses

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

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.

: , : ,

ji ijj j i A j i j A

e i x x

Page 13: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

13

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);beginif 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;

Page 14: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

14

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;

Page 15: Chapter 6 Maximum Flow Problems Flows and Cuts Augmenting Path Algorithm

15

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.