Algorithm Search⌘K

Proofs: Bron-Kerbosch algorithm

These are the human proofs of Bron-Kerbosch algorithm, at full length.

Bron-Kerbosch with pivot lists each maximal clique exactly once full

This proof shows: correctness, termination.

Let G=(V,E)G = (V, E) be a simple undirected graph and N(v)N(v) the set of neighbors of vv. For a clique RR write C(R)={w∈V∖R:R⊆N(w)}C(R) = \{ w \in V \setminus R : R \subseteq N(w) \}, the vertices that extend RR. For a call EXPAND(R,P,X)(R, P, X) let

M(R,P,X)={K:K is a maximal clique of G, R⊆K⊆R∪P}.\mathcal{M}(R, P, X) = \{ K : K \text{ is a maximal clique of } G,\ R \subseteq K \subseteq R \cup P \}.

Precondition (Q). RR is a clique, P∩X=∅P \cap X = \emptyset, and P∪X=C(R)P \cup X = C(R).

Claim. If (Q) holds, EXPAND(R,P,X)(R, P, X) terminates and appends each clique of M(R,P,X)\mathcal{M}(R, P, X) to out exactly once, and nothing else. The top call EXPAND(∅,V,∅)(\emptyset, V, \emptyset) satisfies (Q), since C(∅)=VC(\emptyset) = V, and M(∅,V,∅)\mathcal{M}(\emptyset, V, \emptyset) is the set of all maximal cliques, so BRON-KERBOSCH is correct.

Proof. Induction on ∣P∣|P|.

Base: P=∅P = \emptyset. Then M(R,∅,X)\mathcal{M}(R, \emptyset, X) is {R}\{R\} if RR is maximal and empty otherwise. RR is maximal exactly when C(R)=∅C(R) = \emptyset, that is, when X=∅X = \emptyset. If X=∅X = \emptyset, line L4 appends RR and returns. If X≠∅X \ne \emptyset, line L5 picks some uu, the set P∖N(u)P \setminus N(u) is empty, and the call appends nothing. Both match M\mathcal{M}.

Step: P≠∅P \ne \emptyset. Line L4 does not fire. Let u∈P∪Xu \in P \cup X be the pivot and v1,…,vsv_1, \ldots, v_s the vertices of B=P∖N(u)B = P \setminus N(u) in the order of the loop of line L6. Let PjP_j and XjX_j be the values of PP and XX before iteration jj, so P1=PP_1 = P, X1=XX_1 = X, Pj+1=Pj∖{vj}P_{j+1} = P_j \setminus \{v_j\} and Xj+1=Xj∪{vj}X_{j+1} = X_j \cup \{v_j\}. Then Pj∪Xj=P∪XP_j \cup X_j = P \cup X and Pj∩Xj=∅P_j \cap X_j = \emptyset for each jj, and vj∈Pjv_j \in P_j.

The children satisfy (Q). In iteration jj the child is EXPAND(R′,P′,X′)(R', P', X') with R′=R∪{vj}R' = R \cup \{v_j\}, P′=Pj∩N(vj)P' = P_j \cap N(v_j), X′=Xj∩N(vj)X' = X_j \cap N(v_j). As vj∈C(R)v_j \in C(R), R′R' is a clique. The sets P′P' and X′X' are disjoint, and

P′∪X′=(P∪X)∩N(vj)=C(R)∩N(vj)=C(R′),P' \cup X' = (P \cup X) \cap N(v_j) = C(R) \cap N(v_j) = C(R'),

because a vertex w∉R′w \notin R' extends R′R' exactly when it extends RR and is adjacent to vjv_j. Also ∣P′∣≤∣Pj∣−1<∣P∣|P'| \le |P_j| - 1 < |P|, since vj∉N(vj)v_j \notin N(v_j). By induction, the child terminates and appends exactly M(R′,P′,X′)\mathcal{M}(R', P', X'), each once.

Each clique of M(R,P,X)\mathcal{M}(R, P, X) meets BB. Let K∈M(R,P,X)K \in \mathcal{M}(R, P, X) and suppose K∩B=∅K \cap B = \emptyset. Then K∖R⊆P∩N(u)K \setminus R \subseteq P \cap N(u), so uu is adjacent to every vertex of K∖RK \setminus R, and u∈C(R)u \in C(R) makes it adjacent to every vertex of RR. Also u∉Ru \notin R, and u∉K∖Ru \notin K \setminus R because u∉N(u)u \notin N(u). So K∪{u}K \cup \{u\} is a clique larger than KK, which contradicts the maximality of KK.

The children list M(R,P,X)\mathcal{M}(R, P, X), split by the first branch vertex. For K∈M(R,P,X)K \in \mathcal{M}(R, P, X) let j(K)j(K) be the smallest jj with vj∈Kv_j \in K, which exists by the previous paragraph. We show that K∈M(R′,P′,X′)K \in \mathcal{M}(R', P', X') for iteration jj exactly when j=j(K)j = j(K).

  • If j=j(K)j = j(K): R′=R∪{vj}⊆KR' = R \cup \{v_j\} \subseteq K. A vertex w∈K∖R′w \in K \setminus R' lies in PP and is adjacent to vjv_j. It is not one of v1,…,vj−1v_1, \ldots, v_{j-1}, by the choice of jj, so w∈Pj∩N(vj)=P′w \in P_j \cap N(v_j) = P'. So R′⊆K⊆R′∪P′R' \subseteq K \subseteq R' \cup P'.
  • If j<j(K)j < j(K): vj∉Kv_j \notin K, so R′⊈KR' \not\subseteq K.
  • If j>j(K)j > j(K): vj(K)∈Kv_{j(K)} \in K and vj(K)∈Xjv_{j(K)} \in X_j, so vj(K)∉R′∪P′v_{j(K)} \notin R' \cup P' (it is not vjv_j, and Pj∩Xj=∅P_j \cap X_j = \emptyset), and K⊈R′∪P′K \not\subseteq R' \cup P'.

Conversely, every clique K′K' of M(R′,P′,X′)\mathcal{M}(R', P', X') is maximal, contains RR, and lies in R∪{vj}∪P⊆R∪PR \cup \{v_j\} \cup P \subseteq R \cup P, so it is in M(R,P,X)\mathcal{M}(R, P, X).

So the children together append each clique of M(R,P,X)\mathcal{M}(R, P, X) exactly once, in iteration j(K)j(K), and nothing else. The call itself appends nothing at line L4. The loop has s≤∣P∣s \le |P| iterations, each child terminates, and so the call terminates. This completes the induction. ■\blacksquare

Back to Bron-Kerbosch algorithm