I have been trying to solve Maximum clique problem with the algorithm mentioned below and so far not been able to find a case in which it fails.
Algorithm:
For a given graph, each node numbered from 1 to N.
1. Consider a node as permanent node and form a set of nodes such that each node is connected to this permanent node.(the set includes permanent node as well)
2. Now form a subgraph of the original graph such that it contains all the nodes in the set formed and only those edges which are between the nodes present in the set.
3. Find degree of each node.
4. If all the nodes have same degree then we have a clique.
5. Else delete the least degree node from this subgraph and repeat from step 3.
6. Repeat step 1-5 for all the nodes in the graph.
Can anyone point out flaw in this algorithm?
Here is my code http://pastebin.com/tN149P9m.

- 55
- 10
-
You can find some supposedly hard clique instances here: http://www.nlsde.buaa.edu.cn/~kexu/benchmarks/graph-benchmarks.htm – Niklas B. Mar 25 '14 at 17:07
-
Yes, I formed a graph such that there are 2 or more nodes with least degree. But the deletion order didn't matter in those examples. – atulshgl Mar 25 '14 at 17:07
-
Does it work on a random example? – n. m. could be an AI Mar 25 '14 at 17:09
-
I made some graphs and also used one given on wikipedia page for this problem. – atulshgl Mar 25 '14 at 17:35
-
@atulshgl Write a graph generator and compare your algorithm against a brute-force solution – Niklas B. Mar 25 '14 at 17:36
2 Answers
Here's a family of counterexamples. Start with a k-clique. For each node in this clique, connect it to each node of a fresh copy of K_{k-1,k-1}, i.e., the complete bipartite graph on k-1 plus k-1 nodes. For every permanent node in the clique, the residual graph is its copy of K_{k-1,k-1} and the clique. The nodes in K_{k-1,k-1} have degree k and the other clique nodes have degree k - 1, so the latter get deleted.
Here's a 16-node counterexample, obtained by setting k = 4 and identifying parts of the K_{3,3}s in a ring:
{0: {1, 2, 3, 4, 5, 6, 7, 8, 9},
1: {0, 2, 3, 7, 8, 9, 10, 11, 12},
2: {0, 1, 3, 10, 11, 12, 13, 14, 15},
3: {0, 1, 2, 4, 5, 6, 13, 14, 15},
4: {0, 3, 7, 8, 9, 13, 14, 15},
5: {0, 3, 7, 8, 9, 13, 14, 15},
6: {0, 3, 7, 8, 9, 13, 14, 15},
7: {0, 1, 4, 5, 6, 10, 11, 12},
8: {0, 1, 4, 5, 6, 10, 11, 12},
9: {0, 1, 4, 5, 6, 10, 11, 12},
10: {1, 2, 7, 8, 9, 13, 14, 15},
11: {1, 2, 7, 8, 9, 13, 14, 15},
12: {1, 2, 7, 8, 9, 13, 14, 15},
13: {2, 3, 4, 5, 6, 10, 11, 12},
14: {2, 3, 4, 5, 6, 10, 11, 12},
15: {2, 3, 4, 5, 6, 10, 11, 12}}

- 64,237
- 7
- 60
- 120
-
-
@G.Bach It took a few minutes interspersed with writing an answer to another question, but greedy algorithms like this one tend to blow up in somewhat formulaic ways. – David Eisenstat Mar 25 '14 at 18:09
-
Thanks. Got the flaw. But Such graphs would be of size greater than 20 nodes? – atulshgl Mar 25 '14 at 18:36
-
I made this algorithm while solving a problem which could have maximum 20 nodes and now I was trying to generalize it. – atulshgl Mar 25 '14 at 18:38
-
-
1@atulshgl I didn't try very hard to minimize the size of this counterexample. For k = 4 (the minimum for which it works, on account of spurious 3-cliques involving the K_{k-1,k-1}s), the size is 30 nodes. – David Eisenstat Mar 25 '14 at 18:39
-
-
@atulshgl A dodecahedron with fully connected sides has 20 vertices and should make your algorithm fail – Niklas B. Mar 25 '14 at 18:40
-
@atulshgl It will give the correct answer for k=3, but fail for k=4. Also, if you only care about graphs on at most 20 vertices, then brute force is viable (and always correct). – G. Bach Mar 25 '14 at 18:42
-
@Niklas can you elaborate on dodecahedron with fully connected sides. I couldn't get the fully connected sides part? – atulshgl Mar 25 '14 at 18:47
-
@G.Bach Yaa, you are right. I was just curious to find a faster solution and was able to convert 2^20 solution into a 20^4 solution. :) – atulshgl Mar 25 '14 at 18:55
-
@atulshgl I'm not convinced your algorithm works on every graph with fewer than 20 vertices. Also, 20^4 is only a factor ~6.6 faster than 2^20. – G. Bach Mar 25 '14 at 18:57
-
@atulshgl Edited in a 16-node counterexample, checked using Niklas's code. The k = 4 of the original version actually is 28 nodes. – David Eisenstat Mar 25 '14 at 19:08
-
@DavidEisenstat Got it !!! There can many graphs like the one you mentioned on which this algorithm fails. Thanks for helping. – atulshgl Mar 25 '14 at 19:47
What you propose looks very much like the following sorting algorithm combined with a greedy clique search:
Consider a simple undirected graph G=(V,E)
Initial sorting
Pick the vertex with minimum degree and place it first in the new list L. From the remaining vertices pick the vertex with minimum degree and place it in the second position in L. Repeat the operations until all vertices in V are in L.
Find cliques greedily
Start from the last vertex in L and move in reverse order. For each vertex v in L compute cliques like this:
- Add v to the new clique C
- Compute the neighbor set of v in L: N(v)
- Pick the last vertex in N(v)
- v=w; L=L intersection with N(v);
- Repeat steps 1 to 4
Actually the proposed initial sorting is called a degeneracy ordering and decomposes G in k-cores (see Batagelj et al. 2002 ) A k-core is a maximal subgraph such that all its vertices have at least degree k. The initial sorting leaves the highest cores (with largest k) at the end. When vertices are picked in reverse order you are picking vertices in the highest cores first(similar to your step 4) and trying to find cliques there. There are a number of other possibilities to find cliques greedily based on k-cores but you can never guarantee an optimum unless you do full enumeration.
The proposed initial sorting is used, for example, when searching for exact maximum clique and has been described in many research papers, such as [Carraghan and Pardalos 90]

- 1
- 1

- 347
- 2
- 6