Lably
Skip to content

Bron–Kerbosch algorithm

Algorithm for listing maximal cliques

  • 8 min read
  • 5 chapters

Related on Lably

Through Computer science, Graph (discrete mathematics) and Subset

Although other algorithms for solving the clique problem have running times that are, in theory, better on inputs that have few maximal independent sets, the Bron–Kerbosch algorithm and subsequent improvements to it are frequently reported as being more efficient in practice than the alternatives. It is well-known and widely used in application areas of graph algorithms such as computational chemistry.

A contemporaneous algorithm of Akkoyunlu (1973), although presented in different terms, can be viewed as being the same as the Bron–Kerbosch algorithm, as it generates the same search tree.

Without pivoting

The basic form of the Bron–Kerbosch algorithm is a recursive backtracking algorithm that searches for all maximal cliques in a given graph G. More generally, given three disjoint sets of vertices R, P, and X, it finds the maximal cliques that include all of the vertices in R, some of the vertices in P, and none of the vertices in X. In each call to the algorithm, P and X are disjoint sets whose union consists of those vertices that form cliques when added to R. In other words, P ∪ X is the set of vertices which are joined to every element of R. When P and X are both empty there are no further elements that can be added to R, so R is a maximal clique and the algorithm outputs R.

The recursion is initiated by setting R and X to be the empty set and P to be the vertex set of the graph. Within each recursive call, the algorithm considers the vertices in P in turn; if there are no such vertices, it either reports R as a maximal clique (if X is empty), or backtracks. For each vertex v chosen from P, it makes a recursive call in which v is added to R and in which P and X are restricted to the neighbor set N(v) of v, which finds and reports all clique extensions of R that contain v. Then, it moves v from P to X to exclude it from consideration in future cliques and continues with the next vertex in P.

That is, in pseudocode, the algorithm performs the following steps:

<b id="mwTg">algorithm</b> BronKerbosch1(R, P, X) <b id="mwTw">is</b> <b id="mwUA">if</b> <i id="mwUQ">P</i> <b id="mwUg">and</b> <i id="mwUw">X</i> are both empty <b id="mwVA">then</b> report <i id="mwVQ">R</i> as a maximal clique <b id="mwVg">for each</b> vertex <i id="mwVw">v</i> <b id="mwWA">in</b> <i id="mwWQ">P</i> <b id="mwWg">do</b> BronKerbosch1(<i id="mwWw">R</i> ⋃ {<i id="mwXA">v</i>}, <i id="mwXQ">P</i> ⋂ <i id="mwXg">N</i>(<i id="mwXw">v</i>), <i id="mwYA">X</i> ⋂ <i id="mwYQ">N</i>(<i id="mwYg">v</i>)) <i id="mwYw">P</i> := <i id="mwZA">P</i> \ {<i id="mwZQ">v</i>} <i id="mwZg">X</i> := <i id="mwZw">X</i> ⋃ {<i id="mwaA">v</i>}

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Computing and communication