All problems
Maximum Clique Branch Bound
Problem
Find a lexicographically smallest maximum clique with a branch-and-bound search.
Maintain a candidate set, branch on the node with the most connections inside it, and prune when the current clique plus candidates cannot beat the best. Return the clique as a sorted list of nodes. edges is a list of [u, v] pairs and n is small.
Hint
Coloring-based bounds make maximum clique tractable far beyond the naive O(2^n).
Test cases
case 1
in: [4,[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]]
expected: [0,1,2,3]
case 2
in: [5,[[0,1],[1,2],[2,3],[3,4],[4,0]]]
expected: [0,1]
case 3
in: [5,[[0,1],[0,2],[1,2],[2,3],[3,4],[2,4]]]
expected: [0,1,2]
Starter codePython
def maximum_clique_branch_bound(n, edges):
# Your code here
pass3 test cases · run your code against them in the editor