Proofs: Carraghan-Pardalos algorithm
These are the human proofs of Carraghan-Pardalos algorithm, at full length.
The Carraghan-Pardalos algorithm returns a maximum clique full
This proof shows: correctness, termination.
Let be a finite simple undirected graph and the set of neighbors of . The variable best holds a vertex list; we write for its length and treat it as a set. For a call EXPAND, where is a list of distinct vertices, let
Precondition (Q). is a clique, , and every vertex of is adjacent to every vertex of .
Invariant (B). best is a clique of . It holds at line L2, since is a clique. Line L9 is the only place that changes best, and it sets best to with taken from under (Q), which is a clique. The value never decreases, since line L9 changes best only to a longer list.
Claim. Assume (Q), and that or . Then EXPAND terminates, all its recursive calls satisfy (Q), and when it returns, .
Proof. Induction on .
If is empty, then and . The loop does not run.
Let with . The loop of line L5 removes the first element of the list at each pass of line L7, so it makes at most passes. Before pass the list is . Split the cliques with into and, for each , the cliques whose element of with the smallest position in is . Call the second group . A clique in lies in .
We show: when pass ends without a return, for every ; and when the call returns at line L6 before pass starts, for every with .
- Pass ends. Line L7 takes , and line L8 forms in list order. Each satisfies , since its other vertices outside come after and are adjacent to . If is empty, , and line L9 ensures . If is not empty, line L10 calls EXPAND. This call satisfies (Q): is a clique because is adjacent to all of , and every vertex of is in , so adjacent to all of , and is in . Also . By induction, after it returns, .
- Return at line L6 before pass . Then . Every with lies in , so .
Since never decreases, at the return of the call every in some has : either pass ended, or the call returned at line L6 at or before pass .
It remains to treat . If the first pass returns at line L6, then . Otherwise the first pass ends, and it leaves : either line L9 ran with , or the recursive call EXPAND returned with , since is itself a clique counted by .
So when the call returns. The call terminates, because the loop has at most passes and each recursive call terminates by induction.
Theorem. CARRAGHAN-PARDALOS terminates and returns a maximum clique of .
Proof. Line L3 calls EXPAND with the list of line L1. The precondition (Q) holds trivially, and . By the claim, the call terminates with . By (B), best is a clique, so . So best is a clique of size , and line L4 returns it, sorted. The order of line L1 is not used in the proof, so the result is correct for every order.