The Ford-Fulkerson Algorithm is a classic solution for maximum flow problems.
Let G(V,E) be a graph. For each edge (u,v), its capacity is c(u,v) and flow is f(u,v). We want to find the maximum flow from the source s to sink t.
We put following constraints on the graph:
1. Capacity constraints: ∀(u,v)∈E f(u,v)≤c(u,v).
On any edge, the flow cannot exceed its capacity.
2. Skew symmetry: ∀(u,v)∈E f(u,v)=−f(v,u).
The net flow over (u,v) must be the opposite of the one over (v,u).
3. Flow conservation: ∀u∈V:u≠s∩u≠t⇒∑w∈Vf(u,w)=0.
For any node other than u and v, the net flow should be 0.
We also define the residual network over G as Gf(V,Ef), where the capacity of edges is cf(u,v)=c(u,v)−f(u,v).
The algorithm goes like:
1. f(u,v)←0 for all edges (u,v).
2. While there is a path from s to t in Gf, such that cf(u,v)>0 for all edges (u,v)∈p:
i. Find cf(p)=min{cf(u,v):(u,v)∈p}.
ii. For each edge (u,v)∈p
a. f(u,v)←f(u,v)+cf(p) (Send the flow along the path)
b. f(v,u)←f(v,u)−cf(p) (The flow might be "returned" later)
In step 2, we can use BFS or DFS to find the path.
This algorithm runs in O(Ef) time, where E is the number of edges and f is the maximum flow in the graph.
UPDATE 8/22/12: An interesting theorem that relates to the flow network is the Max-flow Min-cut Theorem. It states
The maximum value of an s-t flow is equal to the minimum capacity over all s-t cuts.
Reference:
Wikipage on Ford-Fulkerson algorithm
Wikipedia page on Max-flow Min-Cut Theorem
No comments:
Post a Comment