I'm trying to understand Bron-Kerbosch's algorithm (with pivoting) to find maximal cliques in an undirected graph. I have some questions:
Is there any criteria for picking a pivot vertex? I have seen some implementations that picked the vertex with the most neighbours for optimization while others simply picked the first vertex in prospective vertices as pivot vertex. How does picking the vertex with the most neighbours help in optimization?
By picking a pivot vertex, it helps to narrow down the list of prospective vertices to check during the search for cliques, thereby reducing the number of recursive calls made. The algorithm without pivoting checks for all vertices to determine whether it forms a clique while the one with pivoting only checks
P \ N(u)for vertices that must be included to form a maximal clique. This way, if a non-maximal clique is found, algorithm can backtrack immediately instead of performing recursion unnecessarily on vertices that will never form a maximal clique. Is my understanding correct?
Pseudocode from Wikipedia:
*Without Pivoting
algorithm BronKerbosch1(R, P, X) is
if P and X are both empty then
report R as a maximal clique
for each vertex v in P do
BronKerbosch1(R ⋃ {v}, P ⋂ N(v), X ⋂ N(v))
P := P \ {v}
X := X ⋃ {v}
*With Pivoting
algorithm BronKerbosch2(R, P, X) is
if P and X are both empty then
report R as a maximal clique
choose a pivot vertex u in P ⋃ X
for each vertex v in P \ N(u) do
BronKerbosch2(R ⋃ {v}, P ⋂ N(v), X ⋂ N(v))
P := P \ {v}
X := X ⋃ {v}