304. Ford–Fulkerson

Find augmenting paths in the network and increase the flow until no more augmenting paths can be found

Example



  • 𝑠: Source
  • 𝐴 & 𝐵: Intermediate nodes
  • 𝑡: Sink

Capacities:

  • 𝑠𝑡: 10
  • 𝑠𝐵: 5
  • 𝐴𝐵: 15
  • 𝐴𝑡: 10
  • 𝐵𝑡: 10

Step 1: Initialize flow to 0

All flows through the edges are initially set to 0.

Step 2: Find an augmenting path

Find an augmenting path using Depth-First Search (DFS). Start from the source 𝑠

𝑠𝐴𝑡

The minimum capacity along this path is 10 (bottleneck on edge 𝐴𝑡)

We can push a flow of 10 units along this path.

Step 3: Update the residual graph

  • 𝑠𝐴: Capacity becomes 1010=0 (no residual capacity)
  • 𝐴𝑡: Capacity becomes 1010=0 (no residual capacity)

Step 4: Find another augmenting path

Find another augmenting path.

We cannot use 𝑠𝐴 or 𝐴𝑡 because their capacities are 0.

𝑠𝐵𝑡

The minimum capacity along this path is 5 (bottleneck on edge 𝑠𝐵)

We can push a flow of 5 units along this path

Step 5: Update the residual graph

  • 𝑠𝐵: Capacity becomes 55=0
  • 𝐵𝑡: Capacity becomes 105=5

Step 6: Termination

No more augmenting paths from 𝑠 to 𝑡 can be found, as all edges from 𝑠 are fully saturated

Maximum flow:

  • 𝑠𝐴𝑡: 10 units
  • 𝑠𝐵𝑡: 5 units

Thus, the maximum flow from source 𝑠 to sink 𝑡 is 15 units

Step 7: Final Flow Distribution