Chapter 2
NP Completeness II
By
Sariel Har-Peled
, September 17, 2007
±
Version: 1.02
2.1
Max-Clique
Figure 2.1: A clique of size 4
inside a graph with 8 vertices.
We remind the reader, that a
clique
is a complete graph,
where every pair of vertices are connected by an edge. The
MaxClique
problem asks what is the largest clique appearing
as a subgraph of
G
. See Figure 2.1.
Problem:
MaxClique
Instance:
A graph
G
Question:
What is the largest number of nodes
in
G
forming a complete subgraph?
Note that
MaxClique
is an
optimization
problem, since the output of the algorithm is a number
and not just true
/
false.
The ﬁrst natural question, is how to solve
MaxClique
. A naive algorithm would work by
enumerating all subsets
S
⊆
V
(
G
), checking for each such subset
S
if it induces a clique in
G
(i.e.,
all pairs of vertices in
S
are connected by an edge of
G
). If so, we know that
G
S
is a clique, where
G
S
denotes the
induced subgraph
on
S
deﬁned by
G
; that is, the graph formed by removing all
the vertices are not in
S
from
G
(in particular, only edges that have both endpoints in
S
appear in
G
S
). Finally, our algorithm would return the largest
S
encountered, such that
G
S
is a clique. The
running time of this algorithm is
O
±
2
n
n
2
²
as can be easily veriﬁed.
TIP
Suggestion 2.1.1
When solving any algorithmic problem, always try ﬁrst to ﬁnd a simple (or even
naive) solution. You can try optimizing it later, but even a naive solution might give you useful
insight into a problem structure and behavior.
±
This work is licensed under the Creative Commons Attribution-Noncommercial 3.0 License. To view a copy of
this license, visit
http://creativecommons.org/licenses/by-nc/3.0/
or send a letter to Creative Commons,
171 Second Street, Suite 300, San Francisco, California, 94105, USA.
1