Proofs: Recursive largest first
These are the human proofs of Recursive largest first, at full length.
RLF builds maximal independent classes and a proper coloring full
This proof shows: correctness, termination.
Number the passes of the outer loop (line L2) by . Let be the set at line L3 of pass , and let be the set of vertices that receive color .
Invariant of the inner loop. At line L8 of pass :
- (the vertices colored so far), and are disjoint and their union is ;
- is independent;
- no vertex of has a neighbor in ;
- every vertex of has a neighbor in .
Initialization. At line L3, , and . Line L4 picks , which exists because by line L2.
Maintenance. Each turn of the loop starts with a vertex (from line L4 or line L9, both choose from , which is nonempty). Before line L6, the invariant holds with , so by part 3, has no neighbor in , and is independent. Line L6 moves from to , which keeps part 1. After line L6, a vertex of may be a neighbor of ; line L7 moves exactly these to , which restores part 3 and keeps part 4, since each moved vertex has the neighbor . Vertices already in keep their neighbor in . So the invariant holds at line L8.
Termination of the inner loop. Each turn removes from , so falls by at least one, and line L8 exits when .
Maximality. At exit, , so by part 1 every vertex of is in , and by part 4 it has a neighbor in . So is an independent set of to which no vertex of can be added: a maximal independent set of . Line L6 removed exactly from , so .
Termination of the outer loop. contains the vertex chosen at line L4, so falls by at least one in each pass, and after at most passes . Every vertex is colored, because it leaves only at line L6.
Properness. Let be an edge. If , both are in , which is independent by part 2, a contradiction. So .
The degree bound. Let . For each , the vertex was in , so by maximality it has a neighbor in . These neighbors are distinct, as they have distinct colors, so . ∎