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 specied nodes: source (s) and sink (t). Since the network is assumed to be simple, an arc is identied 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 c(x; y ). The ow must satisfy 0 f (x; y ) c(x; 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 ) < c(x; y ), assign the label (x+ ; "(y )), where "(y ) = minf"(x); c(x; 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; x)g: (Such y are now labeled and unscanned.) Now dene 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). 1 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 c(x; y ); f (x; y ). The initial ow sends one unit along the path (s; x; y; t). x 1, 1 s 3, 0 1, 1 t 1, 0 3, 0 1, 1 y 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 ( , ) s 3, 0 1, 1 t 1, 0 scanned 3, 0 1, 1 y (s +, 3) unscanned After two steps in Routine A: (y +, 1) unscanned x 1, 1 ( , ) s 3, 0 1, 1 t 1, 0 scanned 3, 0 1, 1 y (s +, 3) scanned 2 After three steps in Routine A: (y +, 1) scanned x 1, 1 , ( ) 3, 0 s 1, 1 (x +, 1) t 1, 0 unscanned scanned 3, 0 1, 1 y (s +, 3) scanned Breakthrough. We now execute Routine B to obtain new ows: x 1, 1 s 3, 1 1, 1 t 1, 1 3, 1 1, 1 y After repeating Routine A, we nish with the following labels. (y -, 1) x 1, 1 ( , ) s 3, 1 1, 1 t 1, 1 3, 1 (x +, 1) 1, 1 y (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 ( , ) s 3, 2 1, 0 t 1, 1 3, 2 1, 1 y 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 ( , ) s 3, 2 1, 0 t 1, 1 3, 2 1, 1 y (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 a pathology when the data are p with a maximum ow. Chvatal[2] describes k +2 irrational. Let = ( 5 , 1)=2 (note the critical property: = k , k+1 for all k = 1; 2; : : :) The following network [1] has arc capacities equal to 1 + , except three arcs: c(3; 6) = 1; c(1; 2) = c(4; 6) = : 1 s 3 1 σ σ 6 4 2 5 4 t 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 6(k + 1) + 1 Augmenting Path x12 x36 x46 (s; 1; 2; 3; 6; t) 1 , 3k+2 , 3k+1 (s; 2; 1; 3; 6; 5; t) , 3k+2 1 , 3k+1 (s; 1; 2; 4; 6; t) 1 , 3k+3 (s; 2; 1; 4; 6; 3; t) , 3k+3 1 , 3k+3 3k +3 (s; 1; 2; 5; 6; t) 1, (s; 2; 1; 5; 6; 4; t) , 3k+4 1 , 3k+3 , 3k+4 (s; 1; 2; 3; 6; t) 1 , 3(k+1)+2 , 3(k+1)+1 Limit: 1 This table appeared in [1]. x65 0 3k +2 3k+2 3k+2 3k+4 0 0 0 References [1] D.P. Bertsekas. Linear Network Optimization: Algorithms and Codes. MIT Press, Cambridge, MA, 1991. [2] V. Chvatal. 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. 5