Bron-Kerbosch with pivot lists each maximal clique exactly once full
This proof shows: correctness, termination.
Let G=(V,E) be a simple undirected graph and N(v) the set of neighbors of v. For a clique R write C(R)={w∈V∖R:R⊆N(w)}, the vertices that extend R. For a call EXPAND(R,P,X) let
M(R,P,X)={K:K is a maximal clique of G, R⊆K⊆R∪P}. Precondition (Q). R is a clique, P∩X=∅, and P∪X=C(R).
Claim. If (Q) holds, EXPAND(R,P,X) terminates and appends each clique of M(R,P,X) to out exactly once, and nothing else. The top call EXPAND(∅,V,∅) satisfies (Q), since C(∅)=V, and M(∅,V,∅) is the set of all maximal cliques, so BRON-KERBOSCH is correct.
Proof. Induction on ∣P∣.
Base: P=∅. Then M(R,∅,X) is {R} if R is maximal and empty otherwise. R is maximal exactly when C(R)=∅, that is, when X=∅. If X=∅, line L4 appends R and returns. If X=∅, line L5 picks some u, the set P∖N(u) is empty, and the call appends nothing. Both match M.
Step: P=∅. Line L4 does not fire. Let u∈P∪X be the pivot and v1,…,vs the vertices of B=P∖N(u) in the order of the loop of line L6. Let Pj and Xj be the values of P and X before iteration j, so P1=P, X1=X, Pj+1=Pj∖{vj} and Xj+1=Xj∪{vj}. Then Pj∪Xj=P∪X and Pj∩Xj=∅ for each j, and vj∈Pj.
The children satisfy (Q). In iteration j the child is EXPAND(R′,P′,X′) with R′=R∪{vj}, P′=Pj∩N(vj), X′=Xj∩N(vj). As vj∈C(R), R′ is a clique. The sets P′ and X′ are disjoint, and
P′∪X′=(P∪X)∩N(vj)=C(R)∩N(vj)=C(R′), because a vertex w∈/R′ extends R′ exactly when it extends R and is adjacent to vj. Also ∣P′∣≤∣Pj∣−1<∣P∣, since vj∈/N(vj). By induction, the child terminates and appends exactly M(R′,P′,X′), each once.
Each clique of M(R,P,X) meets B. Let K∈M(R,P,X) and suppose K∩B=∅. Then K∖R⊆P∩N(u), so u is adjacent to every vertex of K∖R, and u∈C(R) makes it adjacent to every vertex of R. Also u∈/R, and u∈/K∖R because u∈/N(u). So K∪{u} is a clique larger than K, which contradicts the maximality of K.
The children list M(R,P,X), split by the first branch vertex. For K∈M(R,P,X) let j(K) be the smallest j with vj∈K, which exists by the previous paragraph. We show that K∈M(R′,P′,X′) for iteration j exactly when j=j(K).
- If j=j(K): R′=R∪{vj}⊆K. A vertex w∈K∖R′ lies in P and is adjacent to vj. It is not one of v1,…,vj−1, by the choice of j, so w∈Pj∩N(vj)=P′. So R′⊆K⊆R′∪P′.
- If j<j(K): vj∈/K, so R′⊆K.
- If j>j(K): vj(K)∈K and vj(K)∈Xj, so vj(K)∈/R′∪P′ (it is not vj, and Pj∩Xj=∅), and K⊆R′∪P′.
Conversely, every clique K′ of M(R′,P′,X′) is maximal, contains R, and lies in R∪{vj}∪P⊆R∪P, so it is in M(R,P,X).
So the children together append each clique of M(R,P,X) exactly once, in iteration j(K), and nothing else. The call itself appends nothing at line L4. The loop has s≤∣P∣ iterations, each child terminates, and so the call terminates. This completes the induction. ■