Successive Shortest Paths for Min-Cost Flow

The Successive Shortest Paths (SSP) algorithm solves the min-cost flow problem by repeatedly finding the cheapest augmenting path in the residual graph (using Bellman-Ford, since residual costs can be negative), pushing as much flow as possible along it, and updating the residual graph until the demand is met.

Step 1 of 157%

Tutorial

The Successive Shortest Paths Algorithm

The min-cost flow problem: given a network with edge capacities c(u,v)c(u,v) and edge costs w(u,v)w(u,v), ship dd units of flow from a source ss to a sink tt at minimum total cost.

The Successive Shortest Paths (SSP) algorithm builds the optimal flow one path at a time:

  1. Initialize f0f \equiv 0 on every edge.
  2. While f<d:|f| < d{:}
    • Find a minimum-cost ss-tt path PP in the residual graph Gf.G_f.
    • Let Δ=min ⁣(df, minePr(e)),\Delta = \min\!\left( d - |f|,\ \min\limits_{e \in P} r(e) \right), where r(e)r(e) is the residual capacity of edge e.e.
    • Push Δ\Delta units along P:P{:} the total cost increases by Δc(P),\Delta \cdot c(P), where c(P)=ePw(e).c(P) = \sum\limits_{e \in P} w(e).
    • Update Gf.G_f.

If at some iteration no ss-tt path exists in Gf,G_f, the demand is infeasible.

Residual graphs can contain negative-cost edges (introduced when previously-pushed flow is reversed), so shortest paths are computed with Bellman-Ford rather than Dijkstra.

On the first iteration the residual graph equals the original network, so we just enumerate the directed ss-tt paths and pick the cheapest. The maximum amount we can push along it is the smallest capacity on the path -- the bottleneck.

For instance, in the network with edges (uv: cap,cost)(u \to v{:}\ \text{cap}, \text{cost})

sa: (3,1),sb: (5,4),at: (4,6),bt: (2,1),s \to a{:}\ (3, 1), \quad s \to b{:}\ (5, 4), \quad a \to t{:}\ (4, 6), \quad b \to t{:}\ (2, 1),

there are two ss-tt paths:

  • sat:s \to a \to t{:} cost 1+6=7,1+6=7, bottleneck min(3,4)=3.\min(3,4)=3.
  • sbt:s \to b \to t{:} cost 4+1=5,4+1=5, bottleneck min(5,2)=2.\min(5,2)=2.

The cheapest is sbt,s \to b \to t, along which we can push at most 22 units.

navigate · Enter open · Esc close · ⌘K/Ctrl K toggle