Algorithm Search⌘K

Proofs: Cycle-canceling algorithm

These are the human proofs of Cycle-canceling algorithm, at full length.

Cycle canceling returns a minimum-cost maximum flow full

This proof shows: correctness, termination.

Let G=(V,E)G = (V, E) be a directed graph with integer capacities c(e)≥0c(e) \ge 0, integer costs w(e)w(e) and s≠ts \ne t. 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, with w(e+)=w(e)w(e^+) = w(e) and w(e−)=−w(e)w(e^-) = -w(e), and w(f)=∑ew(e)f(e)w(f) = \sum_e w(e) f(e).

Claim 1 (canceling keeps a maximum flow and lowers the cost). Let CC be a cycle of GfG_f and 0<δ≤min⁡a∈Ccf(a)0 < \delta \le \min_{a \in C} c_f(a). Pushing δ\delta around CC as in line L8 gives residual capacities that are nonnegative and satisfy cf(e+)+cf(e−)=c(e)c_f(e^+) + c_f(e^-) = c(e), so ff stays within its bounds. At each vertex of CC one arc of CC enters and one leaves, so the net flow at every vertex, including ss and tt, is unchanged: ff is still a maximum flow. Pushing δ\delta on e+e^+ raises f(e)f(e) by δ\delta and changes the cost by δw(e)\delta w(e); on e−e^- it lowers f(e)f(e) by δ\delta and changes the cost by −δw(e)=δw(e−)-\delta w(e) = \delta w(e^-). So the cost changes by δ⋅w(C)\delta \cdot w(C). □\square

Claim 2 (negative cycle optimality). A maximum flow ff has least cost among maximum flows if and only if GfG_f has no cycle of negative cost.

Proof. If GfG_f has a negative cycle, Claim 1 gives a cheaper maximum flow. Conversely, let f∗f^* be any maximum flow and set g(e+)=max⁡(f∗(e)−f(e),0)g(e^+) = \max(f^*(e) - f(e), 0) and g(e−)=max⁡(f(e)−f∗(e),0)g(e^-) = \max(f(e) - f^*(e), 0). Then 0≤g≤cf0 \le g \le c_f arc by arc, gg is positive only on arcs of GfG_f, and since ff and f∗f^* have the same net flow at every vertex (0 inside, and ±\pm the common maximum value at ss and tt), gg is a circulation. Its cost is ∑ew(e)(f∗(e)−f(e))=w(f∗)−w(f)\sum_e w(e)(f^*(e) - f(e)) = w(f^*) - w(f). By flow decomposition, a circulation is a sum of positive multiples of cycles in its support, so w(f∗)−w(f)w(f^*) - w(f) is a nonnegative combination of costs of cycles of GfG_f. If none is negative, w(f∗)≥w(f)w(f^*) \ge w(f). □\square

Claim 3 (line L4 to L7 find a negative cycle exactly when one exists). Line L4 is Bellman-Ford on GfG_f from a virtual source joined to every vertex by an arc of cost 0. If GfG_f has no negative cycle, a shortest path from the virtual source has at most nn arcs, the first of which is a virtual arc of cost 0, so after n−1n - 1 rounds over the real arcs all values are final and round nn changes nothing. If GfG_f has a negative cycle, the values along it cannot all be final, since summing d(v)≤d(u)+w(u,v)d(v) \le d(u) + w(u, v) around the cycle would give 0≤w(C)<00 \le w(C) < 0; so some round changes a value, and every round up to nn does. By the standard lemma for Bellman-Ford (see negative cycle detection), when a value changes in round nn, the predecessor graph contains a cycle reachable backward from the changed vertex within nn steps, and every cycle of the predecessor graph has negative cost. Line L6 walks nn predecessor steps, which is enough to enter that cycle, and line L7 reads it. Each predecessor arc was set while it had cf>0c_f > 0, and Bellman-Ford does not change cfc_f, so the cycle lies in GfG_f.

Claim 4 (termination). All data are integers, so each cfc_f is an integer, δ≥1\delta \ge 1, and a negative cycle has w(C)≤−1w(C) \le -1. By Claim 1 each cancellation lowers w(f)w(f) by at least 1. Every ff with 0≤f≤c0 \le f \le c has w(f)≥−∑e∣w(e)∣c(e)w(f) \ge -\sum_e |w(e)| c(e), so the loop ends.

Claim 5 (optimality). Line L2 gives a maximum flow, Claim 1 keeps it maximum, and the loop ends (Claim 4) when, by Claim 3, GfG_f has no negative cycle. By Claim 2 the flow returned has least cost among maximum flows. ■\blacksquare

Back to Cycle-canceling algorithm