31 Intro Flows
31 Intro Flows
31 Intro Flows
Maximum Flows
● Dynamic Programming
● Greedy Algorithms
● Incremental improvements
2
Network Flows
Except sources (no incoming flow) and sinks (no outgoing flow)
4
Network Flows
Flow:
Each edge (u,v) carries a flow f(u,v)
For any node x incoming flow is equal to outgoing flow
Sum of flow f( - , x) = Sum of flow f(x, - )
[Conservation of Flow]
Except sources (no incoming flow) and sinks (no outgoing flow)
s t
[INTERPRETATION]
Sum of flow f(s, - ) ? Sum of flow f( - , t)
5
Network Flows
Constrained Flow:
Each edge has a capacity c(x,y),
such that f(x,y) <= c(x,y) [Capacity Constraint]
6
Maximum Flow Graph
7
Maximum Flow Graph
If there exist a s-t path, push maximum possible flow through it.
9
Maximum Flow Simple Algorithm
If there exist a s-t path, push maximum possible flow through it.
10
Ford Fulkerson Algorithm
Algorithm:
● Initialize all f(u,v) to zero
● While (s-t path P exist in residual graph) // Augmenting Path
○ Push bottle neck capacity flow f along the path P
○ Update Residual Graph by adding reverse edges with
bottle-neck capacity.
Examples? Complexity?
img src: geeksforgeeks
12
Ford Fulkerson Algorithm (Examples)
Algorithm:
● Initialize all f(u,v) to zero
● While (s-t path P exist in residual graph) // Augmenting Path
○ Push bottle neck capacity flow f along the path P
○ Update Residual Graph by adding reverse edges with
bottle-neck capacity.
For all forward edges (u,v) => f(u,v)= f(u,v)+f
c(v,u)=c(u,v)+f
For all reverse edges (v,u) => f(u,v) = f(u,v)-f
c(v,u) = c(u,v)-f
14
Ford Fulkerson Algorithm
Algorithm:
● Initialize all f(u,v) to zero
● While (s-t path P exist in residual graph) // Augmenting Path
○ Push bottle neck capacity flow f along the path P
○ Update Residual Graph by adding reverse edges with
bottle-neck capacity.
Complexity?
15
Ford Fulkerson Algorithm
Algorithm:
● Initialize all f(u,v) to zero
● While (s-t path P exist in residual graph) // Augmenting Path
○ Push bottle neck capacity flow f along the path P
○ Update Residual Graph by adding reverse edges with
bottle-neck capacity.
Complexity?
Unit Capacity:
Integral Case:
General Case:
img src: geeksforgeeks
16
Ford Fulkerson Algorithm
INTEGRALITY:
Integer Capacities=>Integer Bottle-neck capacity=>Integer capacities
1000 1000
1000 1000
17
Ford Fulkerson Algorithm
https://cs.stackexchange.com/questions/92875/does-minimum-cost-flow-problem-work-
for-real-valued-edge-weights-costs
18
Ford Fulkerson Algorithm
Algorithm:
● Initialize all f(u,v) to zero
● While (s-t path P exist in residual graph) // Augmenting Path
○ Push bottle neck capacity flow along the path P
○ Update Residual Graph by adding reverse edges with
bottle-neck capacity.
Correctness?
Polynomial Time?
19