(Written in 2019.3)
1
R := is the set of nodes of a maximal clique.
P := is the set of possible nodes in a maximal clique.
X := is the set of nodes that are excluded.
BronKerbosch1(∅, all nodes, ∅)
BronKerbosch1(R, P, X):
if P and X are both empty:
report R as a maximal clique
for each vertex v in P:
BronKerbosch1(
R ⋃ {
v},
P ⋂ N(v),
X ⋂ N(v)
)
P := P \ {
v}
X := X ⋃ {
v}
2
"pivot vertex" u
chosen from P ⋃ X.
Any maximal clique must include either u or one of its non-neighbors, for otherwise the clique could be augmented by adding u to it.
Therefore, only u and its non-neighbors need to be tested as the choices for the vertex v that is added to R in each recursive call to the algorithm.
最大团此时是u邻居的集合,u必然包含在内
疑问,若 P \ N(u) 为空, 则所有顶点皆与u相邻,则此时应该