We consider connected graphs that are weighted and undirected, with two distinguished vertices:
- the source usually called s
- the sink usually called t
The weights are positive.
- the water/data can go either way in an edge
- it cannot exceed the capacity of the edge
- except for s and t, the incoming flow must be equal to the outgoing flow. Only outgoing from s, only incoming to t
This is a correct flow passing through the graph
This is an incorrect flow passing through the graph
Let
-
Antisymmetry:
$f(x → y) = −f(y → x)$ : Meaning that a flow going from x to y with flow of 3, means there is a negative flow of -3 going from y to x; -
Capacity:
$−C(x – y) ≤ f(x → y) ≤ C(x – y)$ : By the previous conditions ; -
flow conservation:
$\Sigma y∈V f(x → y) = 0$ , for$x \neq s$ and$x \neq t$ . - Outgoing flow are positive, and incoming ones are negative
The Ford-Fulkerson algorithm allow to find the maximal flow in a network. Take note that there may be one solution among many others. The result is not always the same.
The complexity is hard to express as it depends on the result and on the minValue
The residual network of a network allows a different representation of the flow, it depict to us how the flow can be directed to find augmented path.
With an edge x—y, you can materialize the residual graph by creating 2 edges with their own weight
- x→y: weight = C(x—y) - f(x→y)
- y→x: weight = C(x—y) - f(y→x)
- The flow
$x—y$ weight 2 is changed to 1. It represent the flow that can pass through x to y$f(x → y) = 2 ⇒ x — 1 → y, as C(x – y) − f(x → y) = 3 − 2 = 1$
- The flow
$y—x$ weight -2 is changed to 5. It represent the flow that can pass through y to x as you can remove 2 from the actual flow going from x to y and add 3$f(y → x) = −2 ⇒ y — 5 → x, as C(y – x) − f(y → x) = 3 − (−2) = 5$
Example:
Let Gf be the residual network associated to the flow f
2 Theorems:
- If there is no improving path, then f is a maximum flow
- If there is an improving path P of minValue λ, then adding λ to every edge of P results in a flow, whose value is increased by λ
Example:
def FordFulkerson(G, s, p):
f = null flow (0 for all edge)
while there is an improving path do :
P = improving path of Gf
λ = minvalue of P
update f by adding λ on edges in P
return fTheses steps is giving you the idea. Every times, you find a path, you take the minValue of the path, and you update the graph
Between every steps, you create a new residual network
Edmonds-Karp algorithm is an improvement on Ford-Fulkerson, where the improving path is computed using a BFS
def EdmondKarp(G, s, p):
f = null flow (0 for all edge)
while there is an improving path do :
P = improving path of Gf with a BFS
λ = minvalue of P
update f by adding λ on edges in P
return fThe complexity of Edmond Karp alogithm has a complexity of
In the same settings, a cut in a graph is a collection of edges whose removal disconnect s from t
The minimum cut is the cut that minimizes the sum of the weights
Theorem: value of the minimum cut = value of the maximum flow
To find the minimum cut, nothing more easy !
Take the residual network of the maximum flow, and take every edges that separated them











