# Ford-Fulkerson algorithm

Ford-Fulkerson algorithm

The Ford-Fulkerson algorithm (named for L. R. Ford, Jr. and D. R. Fulkerson) computes the maximum flow in a flow network. It was published in 1956. The name "Ford-Fulkerson" is often also used for the Edmonds-Karp algorithm, which is a specialization of Ford-Fulkerson.

The idea behind the algorithm is very simple: As long as there is a path from the source (start node) to the sink (end node), with available capacity on all edges in the path, we send flow along one of these paths. Then we find another path, and so on. A path with available capacity is called an augmenting path.

Algorithm

Given is a graph $G\left(V,E\right)$, with capacity $c\left(u,v\right)$ and flow $f\left(u,v\right)=0$ for the edge from $u$ to $v$. We want to find the maximum flow from the source $s$ to the sink $t$. After every step in the algorithm the following is maintained:

* $f\left(u,v\right) leq c\left(u,v\right)$. The flow from $u$ to $v$ does not exceed the capacity.
* $f\left(u,v\right) = - f\left(v,u\right)$. Maintain the net flow between $u$ and $v$. If in reality $a$ units are going from $u$ to $v$, and $b$ units from $v$ to $u$, maintain $f\left(u,v\right)=a-b$ and $f\left(v,u\right)=b-a$.
* $sum_v f\left(u,v\right) = 0 Longleftrightarrow f_\left\{in\right\}\left(u\right) = f_\left\{out\right\}\left(u\right)$ for all nodes $u$, except $s$ and $t$. The amount of flow into a node equals the flow out of the node.

This means that the flow through the network is a "legal flow" after each round in the algorithm. We define the residual network $G_f\left(V,E_f\right)$ to be the network with capacity $c_f\left(u,v\right) = c\left(u,v\right) - f\left(u,v\right)$ and no flow. Notice that it can happen that a flow from $v$ to $u$ is allowed in the residualnetwork, though disallowed in the original network: if $f\left(u,v\right)>0$ and $c\left(v,u\right)=0$ then$c_f\left(v,u\right)>0$.

Algorithm Ford-Fulkerson:Inputs Graph $,G$ with flow capacity $,c$, a source node $,s$, and a sink node $,t$:Output A flow $,f$ from $,s$ to $,t$ which is a maximum:# $f\left(u,v\right) leftarrow 0$ for all edges $,\left(u,v\right)$:# While there is a path $,p$ from $,s$ to $,t$ in $,G_f$, such that $,c_f\left(u,v\right) > 0$ for all edges $\left(u,v\right) in p$::## Find $,c_f\left(p\right) = min\left\{c_f\left(u,v\right) ;|; \left(u,v\right) in p\right\}$:## For each edge $\left(u,v\right) in p$:### $f\left(u,v\right) leftarrow f\left(u,v\right) + c_f\left(p\right)$ ("Send flow along the path"):### $f\left(v,u\right) leftarrow f\left(v,u\right) - c_f\left(p\right)$ ("The flow might be "returned" later")

The path in step 2 can be found with for example a breadth-first search or a depth-first search in $G_f\left(V,E_f\right)$. If you use the former, the algorithm is called Edmonds-Karp.

When no more paths in step 2 can be found, $s$ will not be able to reach $t$ in the residualnetwork. If $S$ is the set of nodes reachable by $s$ in the residual network, then the totalcapacity in the original network of edges from $S$ to the remainder of $V$ is on the one handequal to the total flow we found from $s$ to $t$,and on the other hand serves as an upper bound for all such flows.This proves that the flow we found is maximal. See also Max-flow Min-cut theorem.

Complexity

By adding the flow augmenting path to the flow already established in the graph, the maximum flow will be reached when no more flow augmenting paths can be found in the graph. However, there is no certainty that this situation will ever be reached, so the best that can be guaranteed is that the answer will be correct if the algorithm terminates. In the case that the algorithm runs forever, the flow might not even converge towards the maximum flow. However, this situation only occurs with irrational flow values. When the capacities are integers, the runtime of Ford-Fulkerson is bounded by O("E*f"), where "E" is the number of edges in the graph and "f" is the maximum flow in the graph. This is because each augmenting path can be found in O("E") time and increases the flow by an integer amount which is at least 1.

A variation of the Ford-Fulkerson algorithm with guaranteed termination and a runtime independent of the maximum flow value is the Edmonds-Karp algorithm, which runs in O("VE"2) time.

Example

The following example shows the first steps of Ford-Fulkerson in a flow network with 4 nodes, source "A" and sink "D". This example shows the worst-case behaviour of the algorithm. In each step, only a flow of 1 is sent across the network. If you used breadth-first-search instead, you would only need two steps.

PathCapacityResulting flow network
Initial flow network
$A,B,C,D$$min\left(c_f\left(A,B\right), c_f\left(B,C\right), c_f\left(C,D\right)\right)=$
$min\left(c\left(A,B\right)-f\left(A,B\right) ,c\left(B,C\right)-f\left(B,C\right), c\left(C,D\right)-f\left(C,D\right)\right)=$
$min\left(1000-0, 1-0, 1000-0\right)=1$
$A,C,B,D$$min\left(c_f\left(A,C\right), c_f\left(C,B\right), c_f\left(B,D\right)\right)=$
$min\left(c\left(A,C\right)-f\left(A,C\right), c\left(C,B\right)-f\left(C,B\right), c\left(B,D\right)-f\left(B,D\right)\right)=$
$min\left(1000-0, 0-\left(-1\right), 1000-0\right)=1$
After 1998 more steps …
Final flow network

Notice how flow is "pushed back" from "C" to "B" when finding the path "A,C,B,D".

* [http://www.lix.polytechnique.fr/~durr/MaxFlow/ Animation of Ford-Fulkerson algorithm]

References

* Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. "Introduction to Algorithms", Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7. Section 26.2: The Ford-Fulkerson method, pp.651&ndash;664.

* cite journal
author = L. R. Ford
authorlink = L. R. Ford, Jr.
coauthors = D. R. Fulkerson
year = 1956
title = Maximal flow through a network
journal = Canadian Journal of Mathematics
volume = 8
pages = 399--404

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Algoritmo de Ford-Fulkerson — El algoritmo de Ford Fulkerson propone buscar caminos en los que se pueda aumentar el flujo, hasta que se alcance el flujo máximo. Es aplicable a los Flujos maximales. La idea es encontrar una ruta de penetración con un flujo positivo neto que… …   Wikipedia Español

• Algorithme De Ford-Fulkerson — L algorithme de Ford Fulkerson, du nom de ses auteurs L.R. Ford et D.R. Fulkerson, consiste en une procédure itérative qui permet de déterminer un flux (ou flot) de valeur maximale (ou minimale) à partir d un flot constaté. Il s agit donc d un… …   Wikipédia en Français

• Algorithme de ford-fulkerson — L algorithme de Ford Fulkerson, du nom de ses auteurs L.R. Ford et D.R. Fulkerson, consiste en une procédure itérative qui permet de déterminer un flux (ou flot) de valeur maximale (ou minimale) à partir d un flot constaté. Il s agit donc d un… …   Wikipédia en Français

• Algorithme de Ford-Fulkerson — L algorithme de Ford Fulkerson, du nom de ses auteurs L.R. Ford et D.R. Fulkerson, consiste en une procédure itérative qui permet de déterminer un flot (ou flux) de valeur maximale (ou minimale) à partir d un flot constaté. Il s agit donc d un… …   Wikipédia en Français

• D. R. Fulkerson — Delbert Ray Fulkerson (August 14, 1924 – January 10, 1976) was a mathematician who co developed the Ford Fulkerson algorithm, one of the most well known algorithms to solve the maximum flow problem in networks. Fulkerson was brought up in small… …   Wikipedia

• Edmonds-Karp algorithm — In computer science and graph theory, the Edmonds Karp algorithm is an implementation of the Ford Fulkerson method for computing the maximum flow in a flow network in mathcal{O}(|V| cdot |E|^2). It is asymptotically slower than the relabel to… …   Wikipedia

• Dinic's algorithm — is a strongly polynomial algorithm for computing the maximum flow in a flow network, conceived in 1970 by Israeli (formerly Soviet) computer scientist Yefim Dinitz. The algorithm runs in O(V2E) time and is similar to the Edmonds–Karp algorithm,… …   Wikipedia

• L. R. Ford, Jr. — Lester Randolph Ford, Jr. (born September 23, 1927) is an American mathematician specializing in network flow programming, and son of Lester R. Ford, Sr.. His 1956 paper with D. R. Fulkerson on the maximum flow problem established the maxflow… …   Wikipedia

• Algorithmus von Ford und Fulkerson — Der Algorithmus von Ford und Fulkerson (nach seinen Erfindern Lester Randolph Ford junior und Delbert Ray Fulkerson[1]) dient der Berechnung eines maximalen s t Flusses in einem Netzwerk. Er sucht sukzessiv nach flussvergrößernden Pfaden im… …   Deutsch Wikipedia

• Criss-cross algorithm — This article is about an algorithm for mathematical optimization. For the naming of chemicals, see crisscross method. The criss cross algorithm visits all 8 corners of the Klee–Minty cube in the worst case. It visits 3 additional… …   Wikipedia