Sunteți pe pagina 1din 5

Ford-Fulkerson Max Flow Labeling Algorithm

Harvey J. Greenberg University of Colorado at Denver http: carbon.cudenver.edu hgreenbe December 22, 1998
The Ford-Fulkerson max ow labeling algorithm 3, 4 was introduced in the mid-1950's, and became the seminal work that is still applicable. The material presented in this note is taken from their book 5 . We are given a simple network with two speci ed nodes: source s and sink t. Since the network is assumed to be simple, an arc is identi ed by its endpoints: x; y  is the arc from node x to node y . A ow across arc x; y  is denoted by f x; y , and the arc's capacity is cx; y . The ow must satisfy 0  f x; y   cx; y . The algorithm has two parts, which Ford and Fulkerson called Routine A and Routine B, respectively. The rst is a labeling process that searches for a ow augmenting path i.e., a path from s to t for which f c along all forward arcs and f 0 along all backward arcs. If Routine A nds a ow augmenting path, Routine B changes the ow accordingly. Otherwise, no augmenting path exists, and optimality of the current ow is ensured by their theorem:

Theorem. A ow f has maximum value if, and only if, there is no ow augmenting path with
respect to f . We begin with any feasible ow e.g., f = 0. In general, a node is in one of three states: unlabeled, labeled and scanned, or labeled and unscanned. Upon entering Routine A, all nodes are unlabeled. The rst step renders the source labeled and unscanned.
Routine A labeling process. Initially, label the source ,; "s = 1. General step: Select any node, x, that is labeled and unscanned, and let z; "x be its label. To all unlabeled successor nodes, y , such that f x; y  cx; y , assign the label x+ ; "y , where "y  = minf"x; cx; y  , f x; y g: Such y are now labeled and unscanned. To all predecessor nodes, y , that are unlabeled, such that f y; x 0, assign the label x, ; "y , where
"y  = minf"x; f y; xg:

Such y are now labeled and unscanned. Now de ne x to be labeled and scanned. Repeat the general step until the sink is labeled and unscanned, or until no more labels can be assigned. In the former case, go to Routine B; in the latter case, terminate f is a maximum ow.

Routine B  ow change. The sink has been labeled y  ; "t. If the rst part of the label is y + , replace f y; t with f y; t + "t; otherwise, replace f t; y  with f t; y  , "t. Go to node y and treat it the same way: if its label is x+ ; "y , replace f x; y  with f x; y  + "t; if its label is x, ; "y , replace f y; x with f y; x , "t. In either case, go to node x and repeat until the source is reached. Then, discard all labels and return to Routine A.

Example. The following is also taken from the Ford and Fulkerson book. The arc numbers are
cx; y ; f x; y .

The initial ow sends one unit along the path s; x; y; t.
x 1, 1 s 3, 0 y 1, 1 1, 0 3, 0 t

1, 1

The rst execution of Routine A results in breakthrough" i.e., nding a ow augmenting path with the following labels: After one step in Routine A:
x 1, 1 3, 0 1, 1 3, 0 y 1, 0 t

,
scanned

1, 1

(s + , 3)
unscanned

After two steps in Routine A:


(y + , 1)
unscanned x 1, 1 3, 0 1, 1 3, 0 y 1, 0 t

,
scanned

1, 1

(s + , 3)
scanned

After three steps in Routine A:


(y + , 1)
scanned x 1, 1 3, 0 1, 1 3, 0 y 1, 0 t

,
scanned

(x + , 1)
unscanned

1, 1

(s + , 3)
scanned

Breakthrough. We now execute Routine B to obtain new ows:


x 1, 1 s 3, 1 y 1, 1 1, 1 3, 1 t

1, 1

After repeating Routine A, we nish with the following labels.


(y -, 1)
x 1, 1 3, 1 1, 1 3, 1 y 1, 1 t

(x + , 1)

1, 1

(s + , 2)

This shows that the ow can be increased by 1 = "t along the ow augmenting path, s; y; x; t. Working backwards from the sink, the path traverses arc x; t in a forward direction, so its ow increases by 1 f x; t becomes 2. The label at x tells us we traverse arc x; y  in a backward direction, so we decrease that ow by 1 f x; y  becomes 0. We then move to node y , 3

and its label tells us that the ow augmenting path traverses arc s; y  in the forward direction, so its ow increases by 1 f s; y  becomes 2. Since we reach the source s, Routine B terminates, and we return to Routine A with the following ows and initial label:
x 1, 1 3, 2 1, 0 3, 2 y 1, 1 t

1, 1

After executing Routine A, we nd there is no ow augmenting path, so the current ow has the maximum value of 3 units from s to t. The nal labels are shown:
x 1, 1 3, 2 1, 0 3, 2 y 1, 1 t

1, 1

(s + , 1)

Convergence
When the capacities are integer-valued, the ow increases by at least one unit each iteration, so termination must be nite. Further, in this case, it can be shown that it takes at most jV jjE j iterations to terminate atal 2 describes a pathology when the data are p with a maximum ow. Chv irrational. Let =  5 , 1=2 note the critical property: k+2 = k , k+1 for all k = 1; 2; : : : The following network 1 has arc capacities equal to 1 + , except three arcs:
c3; 6 = 1; c1; 2 = c4; 6 = :
1 3 1 4 t 6

The Ford-Fulkerson max ow labeling algorithm yields a sequence of ow increases, but it does not terminate nitely. Here are the iterations that show a pattern of ow augmenting paths that continue cyclically. End of Iteration 6k + 1 6k + 2 6k + 3 6k + 4 6k + 5 6k + 6 6k + 1 + 1 Augmenting Path s; 1; 2; 3; 6; t s; 2; 1; 3; 6; 5; t s; 1; 2; 4; 6; t s; 2; 1; 4; 6; 3; t s; 1; 2; 5; 6; t s; 2; 1; 5; 6; 4; t s; 1; 2; 3; 6; t Limit: This table appeared in 1 .
x12

, , ,

3k +2

1, 1, 1, 1,

x36
3k +2

1 1
3k +3 3k +3 3k +3 3k +1+2

3k +3

, , , ,

x46
3k +1 3k +1 3k +3

x65

3k +2 3k +2 3k +2 3k +4

3k +4

3k +4 3k +1+1

1,

0 0 0

References
1 D.P. Bertsekas. Linear Network Optimization: Algorithms and Codes. MIT Press, Cambridge, MA, 1991. 2 V. Chv atal. Linear Programming. W.H. Freeman and Co., New York, NY, 1983. 3 L.R. Ford, Jr. and D.R. Fulkerson. Maximal Flow Through a Network. Canadian Journal of Mathematics, 8:399 404, 1956. 4 L.R. Ford, Jr. and D.R. Fulkerson. A Simple Algorithm for Finding Maximal Network Flows and an Application to the Hitchcock Problem. Canadian Journal of Mathematics, 9:210 218, 1957. 5 L.R. Ford, Jr. and D.R. Fulkerson. Flows in Networks. Princeton University Press, Princeton, NJ, 1962.

S-ar putea să vă placă și