The Clique AlgorithmAshay DharwadkerH501 Palam Vihar District Gurgaon Haryana 122017 India 


We present a new polynomialtime
algorithm for finding maximal cliques in graphs. It is shown that every
graph with n vertices and minimum vertex degree δ
must have a maximum clique of size at least ⌈n/(n−δ)⌉
and that this condition is the best possible in terms of n and δ.
As a corollary, we obtain new bounds on the famous Ramsey numbers in terms
of the maximum and minimum vertex degrees of the corresponding Ramsey graphs.
The algorithm finds a maximum clique in all known examples of graphs. In
view of the importance of the
P versus NP question, we ask
if there exists a graph for which the algorithm cannot find a maximum clique.
The algorithm is demonstrated by finding maximum cliques for several famous
graphs, including two large benchmark graphs with hidden maximum cliques.
We implement the algorithm in C++ and provide a demonstration program for
Microsoft Windows [download].


Thanks to Klaus D. Witzel
for providing Example 7.20 that serves as the main benchmark for testing
whether this algorithm actually finds a maximum clique in the hardest
known cases. This algorithm was originally
published in the special issue of Baltic Horizons, No. 8 (107), dedicated
to the "270 Years of Graph Theory" conference in honour of Frank Harary at
Eurouniversity, Tallinn, in 2006. We are pleased to announce that
The Clique Algorithm has also been published by
Amazon in 2011. The Endowed Chair of the Institute of Mathematics was bestowed upon
Distinguished Professor Ashay Dharwadker in 2012 to honour his fundamental contributions to Mathematics and Natural Sciences.


In 1972, Karp [1]
introduced a list of twentyone
NPcomplete problems, one of which
was the problem of finding a maximum clique in a graph. Given a graph,
one must find a largest set of vertices such that any two vertices in the
set are connected by an edge. Such a set of vertices is called a maximum
clique of the graph and in general can be very difficult to find. For example,
try to find a maximum clique with five vertices in the complement of the
Frucht graph
[2] shown below in Figure 1.1.
We present a new polynomialtime CLIQUE ALGORITHM for finding maximal cliques in graphs. In Section 2, we provide precise DEFINITIONS of all the terminology used. In Section 3, we present a formal description of the ALGORITHM followed by a small example to show how the algorithm works stepbystep. In Section 4, we show that the algorithm has polynomialtime COMPLEXITY. In Section 5, we give a new condition of SUFFICIENCY for a graph to have a maximum clique of a certain size. We prove that every graph with n vertices and minimum vertex degree δ must have a maximum clique of size at least ⌈n/(n−δ)⌉ and that the algorithm will always find a clique of at least this size. Furthermore, we prove that this condition is the best possible in terms of n and δ by explicitly constructing graphs for which the size of a maximum clique is exactly ⌈n/(n−δ)⌉. As a corollary, we obtain new bounds on the famous Ramsey numbers in terms of the maximum and minimum vertex degrees of the corresponding Ramsey graphs. For all known examples of graphs, the algorithm finds a maximum clique. In view of the importance of the P versus NP question [3], we ask: does there exist a graph for which this algorithm cannot find a maximum clique? In Section 6, we provide an IMPLEMENTATION of the algorithm as a C++ program, together with demonstration software for Microsoft Windows. In Section 7, we demonstrate the algorithm by finding maximum cliques for several EXAMPLES of famous graphs, including two large benchmark graphs with hidden maximum cliques. In Section 8, we list the REFERENCES. 
We begin with precise definitions of all
the terminology and notation used in this presentation, following [4].
We use the usual notation
⌊x⌋
to denote the floor function i.e. the greatest integer not greater
than x and ⌈x⌉
to denote the ceiling function i.e. the least integer not less than
x.
A simple graph G with n vertices consists of a set of vertices V, with V = n, and a set of edges E, such that each edge is an unordered pair of distinct vertices. Note that the definition of G explicitly forbids loops (edges joining a vertex to itself) and multiple edges (many edges joining a pair of vertices), whence the set E must also be finite. The complement G^{C} of a graph G is a simple graph with the same set of vertices as G but {u, v} is an edge in G^{C} if and only if {u, v} is not an edge in G. We may label the vertices of G with the integers 1, 2, …, n. If the unordered pair of vertices {u, v} is an edge in G, we say that u is a neighbor of v and write uv∈E. Neighborhood is clearly a symmetric relationship: uv∈E if and only if vu∈E. The degree of a vertex v, denoted by d(v), is the number of neighbors of v. The minimum degree over all vertices of G is denoted by δ. The adjacency matrix of G is an n×n matrix with the entry in row u and column v equal to 1 if uv∈E and equal to 0 otherwise. A vertex cover C of G is a set of vertices such that for every edge {u,v} of G at least one of u or v is in C. An independent set S of G is a set of vertices such that no unordered pair of vertices in S is an edge. A clique Q of G is a set of vertices such that every unordered pair of vertices in Q is an edge. Given a clique Q of G and a vertex v outside Q, we say that v is adjoinable if the set Q∪{v} is also a clique of G. Denote by ρ(Q) the number of adjoinable vertices of a clique Q of G. A maximal clique has no adjoinable vertices. A maximum clique is a clique with the largest number of vertices. Note that a maximum clique is always maximal but not necessarily vice versa. An algorithm is a problemsolving method suitable for implementation as a computer program. While designing algorithms we are typically faced with a number of different approaches. For small problems, it hardly matters which approach we use, as long as it is one that solves the problem correctly. However, there are many problems for which the only known algorithms take so long to compute the solution that they are practically useless. A polynomialtime algorithm is one whose number of computational steps is always bounded by a polynomial function of the size of the input. Thus, a polynomialtime algorithm is one that is actually useful in practice. The class of all such problems that have polynomialtime algorithms is denoted by P. For some problems, there are no known polynomialtime algorithms but these problems do have nondeterministic polynomialtime algorithms: try all candidates for solutions simultaneously and for each given candidate, verify whether it is a correct solution in polynomialtime. The class of all such problems is denoted by NP. Clearly P ⊆ NP. On the other hand, there are problems that are known to be in NP and are such that any polynomialtime algorithm for them can be transformed (in polynomialtime) into a polynomialtime algorithm for every problem in NP. Such problems are called NPcomplete. The problem of finding a maximum clique is known to be NPcomplete [1]. Thus, if we are able to show the existence of a polynomialtime algorithm that finds a maximum clique in any graph, we could prove that P = NP. The present algorithm is, so far as we know, a promising candidate for the task. One of the greatest unresolved problems in mathematics and computer science today is whether P = NP or P ≠ NP [3]. 
We now present a formal description of
the algorithm. This is followed by a small example illustrating the steps
of the algorithm. We start by defining two procedures.
3.1. Procedure. Given a simple graph G with n vertices and a clique Q of G, if Q has no adjoinable vertices, output Q. Else, for each adjoinable vertex v of Q, find the number ρ(Q∪{v}) of adjoinable vertices of the clique Q∪{v}. Let v_{max} denote an adjoinable vertex such that ρ(Q∪{v_{max}}) is a maximum and obtain the clique Q∪{v_{max}}. Repeat until the clique has no adjoinable vertices. 3.2. Procedure. Given a simple graph G with n vertices and a maximal clique Q of G, if there is no vertex v outside Q such that there is exactly one vertex w in Q that is not a neighbor of v, output Q. Else, find a vertex v outside Q such that there is exactly one vertex w in Q that is not a neighbor of v. Define Q^{v}^{,w} by adjoining v to Q and removing w from Q. Perform procedure 3.1 on Q^{v}^{,w} and output the resulting clique. 3.3. Algorithm. Given as input a simple graph G with n vertices labeled 1, 2, …, n, search for a clique of size at least k. At each stage, if the clique obtained has size at least k, then stop.
V = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12}.
We search for a clique of size at least k = 5. Part I for i = 1 and i = 2 yields cliques Q_{1} and Q_{2} of size 4, so we give the details starting from i = 3. We initialize the clique as Q_{3 }= {i} = {3}. We now perform procedure 3.1. Here are the results in tabular form:
We obtain a maximal clique Q_{3 }= {3, 5, 7, 11, 12} of the requested size k = 5 and the algorithm terminates. 
The algorithm may be applied to any simple
graph and will always terminate in polynomialtime, finding many maximal
cliques. The propositions below establish sufficient conditions on the
input graph which guarantee that the algorithm will find maximal cliques
of a certain size. Specifically, we prove that every graph with
n
vertices and minimum vertex degree δ must have
a maximum clique of size at least ⌈n/(n−δ)⌉
and that the algorithm will always find a clique of at least this size.
Furthermore, we prove that this condition is the best possible in terms
of n and δ by explicitly constructing
graphs for which the size of a maximum clique is exactly
⌈n/(n−δ)⌉.
As a corollary, we obtain new bounds on the famous Ramsey numbers in terms
of the maximum and minimum vertex degrees of the corresponding Ramsey graphs.
The proofs use two fundamental axioms: Euclid's Division Lemma [5]
and the Pigeonhole Principle [6].
Euclid's Division Lemma. Given a positive integer m and any integer n, there exist unique integers q and r with 0 ≤ r < m such that n = qm+r. Pigeonhole Principle. If l letters are distributed into p pigeonholes, then some pigeonhole receives at least ⌈l/p⌉ letters and some pigeonhole receives at most ⌊l/p⌋ letters. 5.1. Proposition. Given a simple graph G with n vertices and an initial clique Q. At each stage of procedure 3.1, if there are l vertices outside Q and the minimum degree among the vertices inside Q is greater than n−⌈l/(n−l)⌉−1, then procedure 3.1 produces a strictly larger clique. Proof. By contradiction. Suppose the clique Q is maximal. Then Q has no adjoinable vertices in G. In the complement graph G^{C}, every vertex outside Q must have a neighbor inside Q. Thus, in the complement graph G^{C}, there are at least l edges (letters) with one end vertex outside Q and the other end vertex inside Q, there being exactly p = n−l vertices inside Q (pigeonholes). By the pigeonhole principle, some vertex inside Q must receive at least ⌈l/p⌉ edges in the complement graph G^{C}. But this is a contradiction because the maximum degree among the vertices inside Q is less than ⌈l/(n−l)⌉ = ⌈l/p⌉ in the complement graph G^{C}, given that the minimum degree among the vertices inside Q is greater than n−⌈l/(n−l)⌉−1 in G by hypothesis. ☐ 5.2. Proposition. Given a clique Q of G, procedure 3.1 always produces a maximal clique of G. Proof. Procedure 3.1 terminates only when there are no adjoinable vertices. By definition, the resulting clique must be maximal. ☐ 5.3. Proposition. Given a simple graph G with n vertices and an initial maximal clique Q. If there are m vertices outside the maximal clique Q and the minimum degree among the vertices inside Q is greater than n−⌈2m/(n−m)⌉−1, then there exists a vertex v outside Q such that there is exactly one vertex w in Q that is not a neighbor of v and procedure 3.2 produces a maximal clique different from Q and of size greater than or equal to the size of Q. Proof. By contradiction. Note that since Q is maximal, there are no adjoinable vertices in G. In the complement graph G^{C}, every vertex outside Q has at least one neighbor inside Q. Suppose that in the complement graph G^{C} every vertex outside Q has more than one neighbor inside Q. Then in the complement graph G^{C} there are at least l = 2m edges (letters) with one end vertex outside Q and the other end vertex inside Q, there being exactly p = n−m vertices inside Q (pigeonholes). By the pigeonhole principle, in the complement graph G^{C} some vertex inside Q must receive at least ⌈l/p⌉ edges. This is a contradiction because by hypothesis the minimum degree among the vertices inside Q is greater than n−⌈l/p⌉−1 in G, so the maximum degree among the vertices inside Q is less than ⌈l/p⌉ in the complement graph G^{C}. Thus, in the complement graph G^{C}, there exists a vertex v outside Q such that v has exactly one neighbor w inside Q. This means that in G there exists a vertex v outside Q such that there is exactly one vertex w in Q that is not a neighbor of v. Now since procedure 3.2 exchanges v and w, a clique different from Q but of the same size as Q is created. Note that in the process some vertices outside the clique might have become adjoinable. Then, procedure 3.2 applies procedure 3.1 that produces a maximal clique different from Q and of size greater than or equal to the size of Q. ☐ 5.4. Proposition. Given a simple graph G with n vertices and minimum vertex degree δ, the algorithm always finds a maximal clique of size at least ⌈n/(n−δ)⌉. Proof. Consider any one turn of part I in the algorithm. After t vertices have been adjoined from a total of n, there are l = n−t vertices outside the clique Q and the minimum degree among the vertices inside Q is certainly greater than or equal to δ. By proposition 5.1, if δ is greater than n−⌈l/(n−l)⌉−1= n−⌈(n−t)/(n−(n−t))⌉−1= n−⌈(n−t)/t⌉−1= n−⌈(n/t)−1⌉−1 = n−⌈n/t⌉, then a strictly larger clique is produced by adjoining a vertex. Hence, as long as t is less than ⌈n/(n−δ)⌉, a vertex can still be adjoined and procedure 3.1 continues. Thus, at least ⌈n/(n−δ)⌉ vertices are adjoined, producing a clique of size at least ⌈n/(n−δ)⌉. By propositions 5.1, 5.2 and 5.3, all of the cliques produced by the algorithm are maximal and of size at least ⌈n/(n−δ)⌉. ☐ 5.5. Proposition. A simple graph G with n vertices and minimum vertex degree δ has a maximal clique of size at least ⌈n/(n−δ)⌉. Proof. By proposition 5.4, the algorithm finds a maximal clique of size at least ⌈n/(n−δ)⌉. ☐ 5.6. Proposition. Given any positive integers n and δ such that 0 < δ < n, there exists a graph G with minimum vertex degree δ and a maximum clique of size ⌈n/(n−δ)⌉. For any such graph the algorithm always finds a maximum clique. Proof. Let n = q(n−δ)+r with 0 ≤ r < n−δ by Euclid's division lemma. There are two cases.
5.7. Corollary. A Ramsey graph R(k, l) with minimum vertex degree δ, maximum vertex degree Δ and n = r(k, l)−1 vertices must satisfy ⌈kδ/(k−1)⌉ < n < l(Δ+1). Proof. By definition, the graph G = R(k,
l)
has no clique of size k and no independent set of size
l.
5.8. Question. For all known examples of graphs, the algorithm finds a maximum clique. In view of the importance of the P versus NP question [3], we ask: does there exist a graph for which this algorithm cannot find a maximum clique? 
We demonstrate the algorithm with a C++
program following the style of [7]. The demonstration
program package [download] contains a detailed
help file and section 7 gives several examples of input/output files for
the program.

We demonstrate the algorithm by running
the program on several famous graphs and two large benchmark graphs with
hidden maximum cliques. In each case, the algorithm finds a maximum clique
in polynomialtime.
7.1. The Tetrahedron [8]. We run the program
on the graph of the Tetrahedron with n = 4 vertices. The algorithm
finds a maximum clique of size k = 4.
7.2. The Complement of the Kuratowski Bipartite Graph K_{3,
3 }[9]. We run the program on the complement
of the Kuratowski bipartite graph
K_{3, 3} with n
= 6 vertices. The algorithm finds a maximum clique of size k = 3.
7.3. The Octahedron [8]. We run the program
on the graph of the Octahedron with n = 6 vertices. The algorithm
finds a maximum clique of size k = 3.
7.4. The Complement of the BondyMurty Graph G_{1 }[4].
We run the program on the complement of the BondyMurty graph G_{1}
with n = 7 vertices. The algorithm finds a maximum clique of size
k
= 3.
7.5. The Turán Graph T_{3, 8 }[10].
We run the program on the Turán Graph T_{3, 8} with
n
= 8 vertices. The algorithm finds a maximum clique of size k = 3.
7.6. The Complement of the Cube [8]. We run
the program on the complement graph of the Cube with
n = 8 vertices.
The algorithm finds a maximum clique of size
k = 4.
7.7. The Complement of the Petersen Graph [11].
We run the program on the complement of the Petersen graph with n
= 10 vertices. The algorithm finds a maximum clique of size k =
4.
7.8. The Complement of the BondyMurty graph G_{2 }[4].
We run the program on the complement of the BondyMurty graph G_{2}
with n = 11 vertices. The algorithm finds a maximum clique of size
k
= 4.
7.9. The Complement of the Grötzsch Graph [12].
We run the program on the complement of the Grötzsch graph with
n
= 11 vertices. The algorithm finds a maximum clique of size
k =
5.
7.10. The Complement of the Herschel Graph [13].
We run the program on the complement of the Herschel graph with
n
= 11 vertices. The algorithm finds a maximum clique of size
k =
6.
7.11. The Icosahedron [8]. We run the program
on the graph of the Icosahedron with n = 12 vertices. The algorithm
finds a maximum clique of size k = 3.
7.12. The Complement of the BondyMurty graph G_{3 }[4].
We run the program on the complement of the BondyMurty graph G_{3}
with n = 14 vertices. The algorithm finds a maximum clique of size
k
= 7.
7.13. The Complement of the BondyMurty graph G_{4 }[4].
We run the program on the complement of the BondyMurty graph G_{4}
with n = 16 vertices. The algorithm finds a maximum clique of size
k
= 9.
7.14. The Ramsey Graph R(4,4) [6]. We
run the program on the Ramsey graph R(4,4) with n = 17 vertices.
The algorithm finds a maximum clique of size k = 3.
7.15. The Complement of the Folkman Graph [14].
We run the program on the complement of the Folkman graph with n
= 20 vertices. The algorithm finds a maximum clique of size k =
10.
7.16. The Complement of the Dodecahedron [8].
We run the program on the complement graph of the Dodecahedron with n
= 20 vertices. The algorithm finds a maximum clique of size k =
8.
7.17. The Complement of the TutteCoxeter Graph [15].
We run the program on the complement of the TutteCoxeter graph with n
= 30 vertices. The algorithm finds a maximum clique of size k =
15.
7.18. The Complement of the Thomassen Graph [16].
We run the program on the complement of the Thomassen graph with
n
= 34 vertices. The algorithm finds a maximum clique of size
k =
14.
7.19. The Complement of the Berge Graph [17].
This is the first benchmark graph with
n = 60 vertices, following
a construction due to Claude Berge. Let G denote the graph of the
Dodecahedron and let H = K_{3} denote the graph of
the Triangle i.e. the clique on three vertices. The
Berge graph G×H
is defined as the graph whose set of vertices is V(G)×V(H)
with an edge connecting vertex (u_{1},v_{1})
with vertex (u_{2},v_{2}) if and only if
either u_{1 }= u_{2} and {v_{1},
v_{2}}
is an edge in H or v_{1 }=
v_{2}
and {u_{1},
u_{2}} is an edge in G.
It is known that the vertices of the Dodecahedron can be properly coloured
with three colours. As a consequence, the complement of the Berge graph
should have a clique with at least twenty vertices. Indeed, the algorithm
finds a maximum clique of size k = 20.
7.20. The Complement of the Witzel Graph [18].
This is the second benchmark graph with
n = 450 vertices, following
a construction due to Klaus D. Witzel. Take thirty disjoint cliques on
fifteen vertices and connect random pairs of cliques by random edges. Shuffle
the labels of the vertices well so that the original cliques are hidden.
Provided this is done carefully without adding too many extra edges, such
a graph should have a maximum independent set with at least 30 vertices
(one vertex from each original clique). Thus, the complement graph should
have a maximum clique with at least 30 vertices. Moreover, the maximum
clique is well and truly hidden in the complement graph. Indeed, the algorithm
finds a maximum clique of size k = 30.

[1]  R.M. Karp, Reducibility among combinatorial problems, Complexity of Computer Computations, Plenum Press, 1972. 
[2]  R. Frucht, Graphs of degree three with a given abstract group, Canad. J. Math., 1949. 
[3]  Stephen Cook, The P versus NP Problem, Official Problem Description, Millennium Problems, Clay Mathematics Institute, 2000. 
[4]  J.A. Bondy and U.S.R. Murty, Graph Theory with Applications, Elsevier Science Publishing Co., Inc, 1976. 
[5]  Euclid, Elements, circa 300 B.C. 
[6]  F.P. Ramsey, On a problem of formal logic, Proc. London Math. Soc., 1930. 
[7]  Stanley Lippman, Essential C++, AddisonWesley, 2000. 
[8]  Plato, Timaeaus, circa 350 B.C. 
[9]  K. Kuratowski, Sur le problème des courbes gauches en topologie, Fund. Math., 1930. 
[10]  P. Turán, An extremal problem in graph theory, Mat. Fiz. Lapok, 1941. 
[11]  J. Petersen, Die Theorie der regulären Graphen, Acta Math., 1891. 
[12]  H. Grötzsch, Ein Dreifarbensatz für dreikreisfreie Netz auf der Kugel, Z. MartinLutherUniv., 1958. 
[13]  A.S. Herschel, Sir Wm. Hamilton's Icosian Game, Quart. J. Pure Applied Math., 1862. 
[14]  J. Folkman, Regular linesymmetric graphs, J. Combinatorial Theory, 1967. 
[15]  H.S.M. Coxeter and W.T. Tutte, The Chords of the NonRuled Quadratic in PG(3,3), Canad. J. Math., 1958. 
[16]  C. Thomassen, Hypohamiltonian and hypotraceable graphs, Discrete Math., 1974. 
[17]  C. Berge, Graphes et Hypergraphes, Dunod, 1970. 
[18]  Klaus D. Witzel, Personal Communication, 2006. 
[19]  Ashay Dharwadker, The Vertex Cover Algorithm, http://www.dharwadker.org/vertex_cover , 2006. 
[20]  Ashay Dharwadker, The Independent Set Algorithm, http://www.dharwadker.org/independent_set , 2006. 
[21]  Ashay Dharwadker, The Vertex Coloring Algorithm, http://www.dharwadker.org/vertex_coloring , 2006. 
Copyright © 2006 by Ashay Dharwadker. All rights reserved. 