Algorithm Search⌘K

Proofs: Capacity scaling max-flow algorithm

These are the human proofs of Capacity scaling max-flow algorithm, at full length.

Capacity scaling makes at most 2m augmentations per phase full

This proof shows: time.worst.

Use the notation of the correctness proof, let FF be the maximum flow value, and assume m≥n−1m \ge n - 1 (otherwise add O(n)O(n) per search).

Lemma 1. At the end of a Δ\Delta-phase, F−∣f∣<mΔF - |f| < m \Delta.

Proof. Let SS be the set of vertices reachable from ss in Gf(Δ)G_f(\Delta); t∉St \notin S because the phase has ended. For every s-t flow gg, ∣g∣−∣f∣≤∑(c(e)−f(e))+∑f(e)|g| - |f| \le \sum (c(e) - f(e)) + \sum f(e), where the first sum is over edges from SS to Sˉ\bar S and the second over edges from Sˉ\bar S to SS, since ∣g∣=g(S,Sˉ)−g(Sˉ,S)≤c(S,Sˉ)|g| = g(S, \bar S) - g(\bar S, S) \le c(S, \bar S) and ∣f∣=f(S,Sˉ)−f(Sˉ,S)|f| = f(S, \bar S) - f(\bar S, S). An edge ee from SS to Sˉ\bar S has c(e)−f(e)=cf(e+)<Δc(e) - f(e) = c_f(e^+) < \Delta, else its head would be reachable in Gf(Δ)G_f(\Delta); an edge from Sˉ\bar S to SS has f(e)=cf(e−)<Δf(e) = c_f(e^-) < \Delta for the same reason. Each edge is in at most one of the two sums, so ∣g∣−∣f∣<mΔ|g| - |f| < m\Delta when some edge crosses the cut, and ∣g∣−∣f∣≤0|g| - |f| \le 0 otherwise. Take gg maximum. □\square

Lemma 2. Each phase performs fewer than 2m2m augmentations, or none.

Proof. The first threshold Δ0\Delta_0 is a power of 2, and line L7 halves it, so every threshold is a power of 2 and each later threshold Δ\Delta follows a phase with threshold exactly 2Δ2\Delta. For the first phase, Δ0≤U<2Δ0\Delta_0 \le U < 2\Delta_0 by the choice in line L2, so F≤c({s},V∖{s})≤mU<2mΔ0F \le c(\{s\}, V \setminus \{s\}) \le mU < 2m\Delta_0. For a later phase with threshold Δ\Delta, Lemma 1 for the previous phase says that the missing value at the start is less than 2mΔ2m\Delta. In every phase each augmentation carries at least Δ\Delta, so the phase has fewer than 2mΔ/Δ=2m2m\Delta / \Delta = 2m augmentations. □\square

Theorem. The algorithm runs in O(m2log⁡U)O(m^2 \log U) time and Θ(n+m)\Theta(n + m) space.

Proof. There are ⌊log⁡2U⌋+1\lfloor \log_2 U \rfloor + 1 phases. Each phase has fewer than 2m2m augmentations, each preceded by one search, plus one failing search; a search costs O(n+m)=O(m)O(n + m) = O(m) and an augmentation O(n)O(n). So a phase costs O(m2)O(m^2) and the total is O(m2log⁡U)O(m^2 \log U), plus O(m)O(m) for lines L1, L2, L8 and L9. The arrays of residual capacities, the adjacency lists, the queue and the parent arcs take Θ(n+m)\Theta(n + m) space. ■\blacksquare

Capacity scaling returns a maximum flow and a minimum cut full

This proof shows: correctness, termination.

Let N=(G,c,s,t)N = (G, c, s, t) be a flow network with integer capacities c(e)≥0c(e) \ge 0, mm edges and s≠ts \ne t, and U=max⁡ec(e)U = \max_e c(e). Write cfc_f for the residual capacities, f(e)=cf(e−)f(e) = c_f(e^-), GfG_f for the residual graph of arcs with cf>0c_f > 0, and Gf(Δ)G_f(\Delta) for the arcs with cf≥Δc_f \ge \Delta.

Claim 1 (invariant). Before and after each augmentation, ff is an s-t flow, every cfc_f is a nonnegative integer, and cf(e+)+cf(e−)=c(e)c_f(e^+) + c_f(e^-) = c(e) for each edge.

Proof. True after line L1. Line L4 finds a path PP of Gf(Δ)⊆GfG_f(\Delta) \subseteq G_f from ss to tt; BFS marks each vertex once, so PP is simple. Line L5 sets δ\delta to the least cfc_f on PP, an integer with δ≥Δ≥1\delta \ge \Delta \ge 1. Line L6 is an augmentation along PP by its bottleneck, which keeps the invariant by the augmentation lemma of augmenting path, and raises ∣f∣|f| by δ\delta. □\square

Claim 2 (termination). Each augmentation raises ∣f∣|f| by at least 1, and ∣f∣≤c({s},V∖{s})|f| \le c(\{s\}, V \setminus \{s\}), so there are finitely many augmentations. Line L7 halves Δ\Delta, so the loop of line L3 runs ⌊log⁡2U⌋+1\lfloor \log_2 U \rfloor + 1 times, or not at all if U=0U = 0.

Claim 3 (no augmenting path at the end). If U≥1U \ge 1, the last phase has Δ=1\Delta = 1 and ends when BFS over the arcs with cf≥1c_f \ge 1 does not reach tt. Since all cfc_f are integers, cf≥1c_f \ge 1 means cf>0c_f > 0, so tt is not reachable in GfG_f. If U=0U = 0, GfG_f has no arcs at all.

Claim 4 (optimality). Line L8 computes the set SS of vertices reachable from ss in GfG_f, with s∈Ss \in S and, by Claim 3, t∉St \notin S. Each edge e=(u,v)e = (u, v) with u∈Su \in S, v∉Sv \notin S has cf(e+)=0c_f(e^+) = 0, so f(e)=c(e)f(e) = c(e); each edge (v,u)(v, u) with v∉Sv \notin S, u∈Su \in S has cf(e−)=0c_f(e^-) = 0, so f(e)=0f(e) = 0. By conservation, ∣f∣=f(S,Sˉ)−f(Sˉ,S)=c(S,Sˉ)|f| = f(S, \bar S) - f(\bar S, S) = c(S, \bar S). Every s-t flow has value at most c(S,Sˉ)c(S, \bar S) and every s-t cut has capacity at least ∣f∣|f|, so the flow is maximum and the cut is minimum. ■\blacksquare

Back to Capacity scaling max-flow algorithm