Computer Science

Network Flow (Max-Flow)

Visualize how the maximum flow in a network is calculated using augmenting paths.

Network Flow (Max-Flow)

Concept Overview

The Maximum Flow problem involves finding a feasible flow through a single-source, single-sink flow network that is maximal. Imagine a network of pipes with different capacities; the goal is to determine the maximum amount of water that can be routed from the source to the destination without exceeding the capacity of any individual pipe. This fundamental optimization problem provides a framework for solving many complex allocation, routing, and scheduling problems.

Mathematical Definition

A flow network is a directed graph G = (V, E) where each edge (u, v) ∈ E has a non-negative capacity c(u, v) ≥ 0. There are two distinguished nodes: a source s and a sink t. A flow is a function f: V × V → ℝ satisfying the following constraints:

1. Capacity Constraint:
For all u, v ∈ V, 0 ≤ f(u, v) ≤ c(u, v)

2. Flow Conservation:
For all u ∈ V \ {s, t},
Σv∈V f(v, u) = Σv∈V f(u, v)

Objective: Maximize the total net flow leaving the source, defined as:
|f| = Σv∈V f(s, v)

Key Concepts

  • Residual Network: The residual network Gf indicates the additional flow that can be pushed along edges given the current flow. For an edge (u, v), the residual capacity is cf(u, v) = c(u, v) - f(u, v). Importantly, if f(u, v) > 0, there is also a residual capacity in the reverse direction: cf(v, u) = f(u, v), allowing flow to be "undone".
  • Augmenting Path: A simple path from s to t in the residual network. If an augmenting path exists, the total flow can be increased by the bottleneck capacity of this path.
  • Ford-Fulkerson Method: An iterative approach that repeatedly finds augmenting paths and pushes flow along them until no more augmenting paths exist. Its runtime depends heavily on the capacities and path selection.
  • Edmonds-Karp Algorithm: A specific implementation of Ford-Fulkerson that uses Breadth-First Search (BFS) to find the shortest augmenting path (in terms of the number of edges). This guarantees termination and runs in O(|V||E|2) time independently of the maximum capacity.
  • Max-Flow Min-Cut Theorem: A fundamental theorem stating that the maximum flow through a network is exactly equal to the capacity of the minimum cut (the smallest total capacity of edges that, if removed, would disconnect the source from the sink).

Historical Context

The Max-Flow problem was first formulated in 1954 by T. E. Harris and F. S. Ross as a simplified model of Soviet railway traffic flow. In 1956, L. R. Ford Jr. and D. R. Fulkerson developed the first known algorithm to solve it and proved the Max-Flow Min-Cut theorem. In 1972, Jack Edmonds and Richard Karp, and independently Yefim Dinitz in 1970, introduced polynomial-time implementations using shortest augmenting paths.

Real-world Applications

  • Transportation Networks: Routing goods from factories to distribution centers while respecting road or rail capacities.
  • Bipartite Matching: Assigning applicants to jobs or students to classes where flow networks can easily model constraints and assignments.
  • Image Segmentation: Using the Max-Flow Min-Cut theorem in computer vision to separate foreground objects from the background in images.
  • Telecommunications: Optimizing packet routing through a data network with bandwidth constraints.

Related Concepts

  • Graph Traversal (BFS/DFS) — foundational algorithms used to find augmenting paths.
  • Dijkstra's Algorithm — related to finding optimal paths, conceptually similar to shortest-path flows.
  • Bipartite Matching — directly solvable by reducing the problem to Max-Flow.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Network Flow (Max-Flow) module.

Try Network Flow (Max-Flow) on Riano →

More in Computer Science