Algorithm Search⌘K

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 k=1,2,…k = 1, 2, \ldots. Let UkU_k be the set UU at line L3 of pass kk, and let CkC_k be the set of vertices that receive color kk.

Invariant of the inner loop. At line L8 of pass kk:

  1. CkC_k (the vertices colored kk so far), PP and WW are disjoint and their union is UkU_k;
  2. CkC_k is independent;
  3. no vertex of PP has a neighbor in CkC_k;
  4. every vertex of WW has a neighbor in CkC_k.

Initialization. At line L3, P=UkP = U_k, W=∅W = \emptyset and Ck=∅C_k = \emptyset. Line L4 picks v∈Pv \in P, which exists because Uk≠∅U_k \ne \emptyset by line L2.

Maintenance. Each turn of the loop starts with a vertex v∈Pv \in P (from line L4 or line L9, both choose from PP, which is nonempty). Before line L6, the invariant holds with v∈Pv \in P, so by part 3, vv has no neighbor in CkC_k, and Ck∪{v}C_k \cup \{v\} is independent. Line L6 moves vv from PP to CkC_k, which keeps part 1. After line L6, a vertex of PP may be a neighbor of vv; line L7 moves exactly these to WW, which restores part 3 and keeps part 4, since each moved vertex has the neighbor v∈Ckv \in C_k. Vertices already in WW keep their neighbor in CkC_k. So the invariant holds at line L8.

Termination of the inner loop. Each turn removes vv from PP, so ∣P∣|P| falls by at least one, and line L8 exits when P=∅P = \emptyset.

Maximality. At exit, P=∅P = \emptyset, so by part 1 every vertex of Uk∖CkU_k \setminus C_k is in WW, and by part 4 it has a neighbor in CkC_k. So CkC_k is an independent set of G[Uk]G[U_k] to which no vertex of UkU_k can be added: a maximal independent set of G[Uk]G[U_k]. Line L6 removed exactly CkC_k from UU, so Uk+1=Uk∖CkU_{k+1} = U_k \setminus C_k.

Termination of the outer loop. CkC_k contains the vertex chosen at line L4, so ∣U∣|U| falls by at least one in each pass, and after at most nn passes U=∅U = \emptyset. Every vertex is colored, because it leaves UU only at line L6.

Properness. Let uwuw be an edge. If c(u)=c(w)=kc(u) = c(w) = k, both are in CkC_k, which is independent by part 2, a contradiction. So c(u)≠c(w)c(u) \ne c(w).

The degree bound. Let c(v)=jc(v) = j. For each i<ji < j, the vertex vv was in Ui∖CiU_i \setminus C_i, so by maximality it has a neighbor in CiC_i. These j−1j - 1 neighbors are distinct, as they have distinct colors, so j−1≤deg⁡(v)j - 1 \le \deg(v). ∎

Back to Recursive largest first