Proofs: Hao-Orlin algorithm
These are the human proofs of Hao-Orlin algorithm, at full length.
The Hao-Orlin algorithm returns a minimum directed cut full
This proof shows: correctness, termination.
Let be directed with capacities , , and root . For a set write . Arcs come in residual pairs, one per edge, and is the residual capacity. Write for inflow minus outflow of at . Order the parts as , then the dormant sets in order of creation, then , and call the last part.
Invariants (at every step of HAO-ORLIN-ROOTED):
- (I1) and for every .
- (I2) If and , then . That is, no residual arc goes from or a dormant set to a later part.
- (I3) For every residual arc with , .
- (I4) and for every ; and the labels of form a set of consecutive integers.
Initialization. After lines L1 to L3, is full on arcs out of and 0 elsewhere, so (I1) holds and every arc from to is full, which is (I2); all labels in are 0, which gives (I3) and (I4).
Push (line L6) along with moves at most , so stays and (I1) holds. It may create the residual arc inside , with , so (I3) holds. It creates no arc out of or a dormant set, so (I2) holds.
Relabel (line L9). Line L9 runs only if has no admissible arc, shares its label with another vertex of , and has a residual arc into . By (I3), each residual arc inside has , and not equal since no arc is admissible, so . The new label is thus at least ; arcs out of satisfy (I3) by the choice, and arcs into only get looser. The new label is for a vertex , so by consecutiveness every value from up to the new label is used, and the old label of is still used by another vertex; so (I4) holds. Since is never relabeled, stays the least.
Gap (line L7). Let , where alone has the label . A residual arc from to would have, by (I3), , so and ; then and the arc is admissible, which is excluded. So has no residual arc to the new , and as a new last dormant set it satisfies (I2). Since and would share the label of if equal, and . The remaining labels are those below , still consecutive. (I1) and (I3) are unaffected.
Isolated vertex (line L8). has no residual arc into , so satisfies (I2) as a new last dormant set. It shares its label (else line L7 applied), so the label set of is unchanged, and .
Termination of a phase. By (I4) the labels in lie in , and is fixed during a phase. Each relabel raises a label by at least 1, so a phase has at most relabels. Between relabels, each vertex scans its arcs with a current-arc pointer; a push saturates an arc or empties . Saturated arcs become residual again only after a push along , which needs , so must have been relabeled; hence there are finitely many saturating pushes. Each non-saturating push empties its vertex; with the potential , which each such push lowers by at least 1 and each relabel or saturating push raises by at most , there are finitely many. Dormant moves shrink . So the loop of line L5 stops, and then no vertex of is active.
The recorded cut is a minimum - cut. At line L10 let , the union of and the dormant sets, so and . By (I2), no arc from to is residual: arcs from to are full, and arcs from to carry no flow, since flow on would make residual. So the net flow into is . Every vertex of other than has excess 0, so . Now let be any set with and . The net flow into is at most , and it equals , which by (I1) is at least , as contains no vertex of . So .
Changing the sink (lines L11 to L14). Moving into and pushing the full residual capacity of every arc from to a vertex outside keeps (I1) (the excess of may become negative, which is allowed in , and the receivers gain excess) and makes every arc from to a later part full, so (I2) holds for . Pushes from into a dormant set create residual arcs into only, which (I2) allows. Removing , the least label, from keeps the labels consecutive. If becomes empty and a dormant set is left, the most recent one becomes . Since its creation, no flow moved on arcs between two of its vertices, as only vertices push and line L12 pushes from ; so its labels still satisfy (I3), and they were consecutive when it was created, by the two cases above. By (I2) no older part has a residual arc into it, so (I2) still holds with as the last part. Line L14 then picks a least label, which gives (I4).
Every vertex other than is a sink once. Each phase moves one vertex from to , and is nonempty at the start of each phase: at line L13 it is refilled while a dormant set remains, and when none remains every vertex is in . After phases . So the sinks are exactly the vertices other than .
Rooted optimality. Every recorded cut contains and not the current sink, so it is a nonempty proper set containing . Let be a proper set containing of least . Since , some sink lies outside it; let be the first. At phase , and , so the cut recorded in phase has capacity at most . Hence the least recorded cut is optimal among sets containing .
Global optimality (line L15). Take . A nonempty proper set either contains 0, and is covered by the forward run, or does not, and then contains 0 and , the capacity of the edges leaving in the reversed graph, covered by the reverse run. Line L15 returns the better of the two, complementing the side found by the reverse run. So it returns a minimum directed cut.