I have a homework question asking for a polynomial algorithm to find a clique of size Ω(logn).
My current implementation is as follows:
- Divide the graph into n^logn microsets (subgraphs) of size logn and store them as adjacency matrices
- For each subgraph, brute force check if S is a clique of size logn
- If S is a clique, return it.
- If we finish iterating without finding a clique, return None (no logn cliques in graph, which is the worst case)
Building the subgraphs will take n^k time. To check if a subgraph is a clique of size logn will take O((logn)^2), as each vertex in the subgraph will have k^2 edges (where k is the clique size, which in this case is logn). This must be done for all n^logn subgaphs, so the total runtime would be O(n^logn +(n^(logn))((logn)^2)).
My questions are:
- Is this polynomial, or does the k as an exponent make it exponential
- Is my logic sound?
- What does the runtime reduce to?
Thanks y'all!
EDIT 1: I realize that the only way to do this in polynomial time is going to involve not creating n^k subgraphs, but rather dividing the graph into n/k components. If I do this, however, there is no way to guarantee that any of my microsets will actually have a k-sized clique even if one is guaranteed in the graph. Is there any way around this?
EDIT 2: One VERY important thing that I failed to mention or consider earlier was that we are given that G has a clique size of n/2. Because of this, we know that the worst case for separating G into n/logn subsets of size logn will result when the maximum clique of n/2 is evenly separated into size logn/2 cliques into each subgraph. This guarantees that we find at least one clique of size logn/2, which satisfies finding a clique of size Ω(logn). This is also polynomial, as it runs in O(n/logn * n^(log2(3)/3) time. Apologies for not providing this earlier!