Network Flows - Edmond Karp
Algorithm
- Copy capacity matrix to residual matrix.
- Use BFS to find path from source to sink.
- If no path is found, stop.
- Find bottleneck flow (minimum residual capacity on path).
- Update residual graph:
- reduce forward edges
- increase backward edges
- Add bottleneck to max flow.
- Repeat from BFS step.
Time Complexity
- O(VE^2)
Space Complexity
- O(V^2)