Home Visualizer Algorithms Docs

Complexity Comparison

Algorithm Time Complexity Space Best For Year
Dinic'sO(V²E)O(V+E)General dense graphs1970
Edmonds-KarpO(VE²)O(V+E)Sparse graphs1972
Push-RelabelO(V²√E)O(V+E)Unit capacity1988
Ford-FulkersonO(E·f*)O(V+E)Small integer caps1956
Capacity ScalingO(E² log U)O(V+E)Large capacities1985
HLPPS (Push-Relabel)O(V²√E)O(V+E)Optimal practical1990

⚡ Dinic's Algorithm

O(V²E) — O(V√E) for unit networks

Constructs a level graph via BFS, then finds blocking flows in the level graph using DFS. Repeats until no augmenting path exists. Significantly faster than Ford-Fulkerson for dense or large networks due to the layered structure.

✓ Fastest general-purpose
✓ Optimal for unit graphs
✓ Works on dense nets
✗ Complex to implement
✗ Overhead for tiny graphs

🔄 Ford-Fulkerson

O(E · max_flow) — depends on capacities

The foundational max-flow algorithm. Iteratively finds augmenting paths in the residual graph using DFS and pushes flow. Simple but may not terminate with irrational capacities. Use Edmonds-Karp (BFS variant) for guaranteed termination.

✓ Simple to understand
✓ Great for teaching
✓ Small integer caps
✗ Can be slow/infinite
✗ Capacity-dependent

🔍 Edmonds-Karp

O(VE²) — polynomial guaranteed

A BFS-based refinement of Ford-Fulkerson that always finds the shortest augmenting path (by hop count). Guarantees polynomial time complexity regardless of edge capacities. Ideal for sparse graphs with moderate node counts.

✓ Polynomial guaranteed
✓ Easy BFS implementation
✓ Sparse graphs
✗ Slower than Dinic's
✗ BFS overhead

📌 Push-Relabel

O(V²E) — O(V²√E) with HLPPS

Works by maintaining a preflow and iteratively pushing excess flow from overflowing nodes. Uses height labels to guide flow. The highest-label variant (HLPPS) achieves near-optimal performance and is used in many production systems.

✓ Near-optimal practical
✓ Local operations
✓ Parallelizable
✗ Harder to implement
✗ Label maintenance cost

📊 Capacity Scaling

O(E² log U) — U = max capacity

Improves Ford-Fulkerson by processing edges in phases based on capacity thresholds. Starts with the largest capacities and scales down, ensuring each phase augments significant flow. Effective when capacity values vary widely.

✓ Good for large caps
✓ Predictable phases
✗ Not always fastest
✗ Scaling overhead

🌐 Min-Cost Max-Flow

O(VE log V · max_flow)

Extends max-flow with edge costs. Finds the maximum flow with minimum total cost. Uses successive shortest paths (Dijkstra/Bellman-Ford) on the residual graph. Essential for assignment problems and transportation networks.

✓ Cost optimization
✓ Assignment problems
✗ Much slower
✗ Negative cycles issue

Key Concepts

Residual Graph

For each edge (u→v, cap c, flow f), the residual graph contains forward edge with remaining capacity (c−f) and backward edge with capacity f. Augmenting paths are found in the residual graph.

Augmenting Path

A path from source S to sink T in the residual graph where every edge has positive residual capacity. Pushing flow along an augmenting path increases total flow.

Max-Flow Min-Cut

By the max-flow min-cut theorem, the maximum flow equals the minimum cut capacity. FlowNet highlights the min-cut partition after running any max-flow algorithm.

Try All Algorithms in Visualizer →