Classic NP-Complete Problems: Clique and Vertex Cover

Suppose you run a social network. You want to find the largest group of people who all know each other — a mutual-friend clique for a group photo feature. This sounds like a query you could optimize your way into. But no known algorithm solves it faster than checking exponentially many candidate groups. The Clique problem and its close cousin Vertex Cover are the canonical examples used to explain what "no known algorithm" really means in complexity theory. They also show why so many practical scheduling, matching, and network problems turn out to be secretly the same problem in disguise. This article builds the NP-completeness of Clique and Vertex Cover from the ground up. It uses The Cook-Levin Theorem as the anchor. Cook-Levin tells us that 3-SAT is NP-complete. Everything else in the NP-complete universe is reached by Polynomial-Time Mapping Reductions. These transform instances of a known-hard problem into instances of a new problem, preserving yes/no answers. We give a full reduction from 3-SAT to Clique. Then we show Clique and Vertex Cover are polynomial-time equivalent via a slick complement-graph trick. This transitively makes Vertex Cover NP-complete too. The big picture is that NP-completeness is a web, not a list. Once you have one anchor problem proven hard by direct simulation of a Turing machine, every subsequent proof is a translation exercise. You design a gadget that mimics the anchor problem's structure inside the new problem's combinatorics. Clique and Vertex Cover are the cleanest gadgets in the canon. There is no arithmetic, no encoding tricks, just graphs. This is why they are the first stop after Cook-Levin in almost every course. By the end you will be able to state and prove both reductions precisely. You will trace them on a concrete 3-SAT formula. You will verify size and correctness bounds. And you will see why this cluster of problems foreshadows harder graph problems like Hamiltonian Path and Circuit Problems, which require more elaborate gadgetry to encode computation.

Key takeaways
  • Clique: does a graph contain a set of k mutually adjacent vertices? Vertex Cover: does a graph have k vertices touching every edge?
  • Both are in NP: a candidate set is a polynomial-size certificate, checkable in polynomial time.
  • 3-SAT ≤p Clique: each literal occurrence becomes a vertex; edges connect compatible literals from different clauses; a k-clique (k = number of clauses) encodes a satisfying assignment.
  • Clique ≤p Vertex Cover (and back): a set S is a clique in G iff V − S is a vertex cover of the complement graph Ḡ.
  • Both reductions run in polynomial time and preserve answers exactly, so NP-hardness of 3-SAT transfers to both problems, and membership in NP makes them NP-complete.
  • The same "cover the constraints with a bounded budget" pattern reappears throughout complexity theory, including in the machinery behind Hamiltonian Path and Circuit Problems.
The core insight

A satisfying assignment for a 3-CNF formula corresponds exactly to a k-clique in a graph built one vertex per literal occurrence and one edge per pair of simultaneously-satisfiable literals from different clauses.

The idea

A clique in an undirected graph G=(V,E)G = (V,E) is a subset C⊆VC \subseteq V such that every two distinct vertices in CC are joined by an edge. The Clique problem, as a decision problem, asks: given GG and an integer kk, does GG contain a clique of size at least kk? A vertex cover is a subset S⊆VS \subseteq V such that every edge of GG has at least one endpoint in SS. The Vertex Cover problem asks: given GG and integer kk, is there a vertex cover of size at most kk? Both problems are phrased as decision problems (yes/no) rather than optimization problems, which is the standard convention in complexity theory — it lets us compare them cleanly against other decision problems like 3-SAT via Polynomial-Time Mapping Reductions. Recall that a reduction ff from language AA to language BB, written A≤pBA \le_p B, is a polynomial-time computable function such that x∈A  ⟺  f(x)∈Bx \in A \iff f(x) \in B. If AA is NP-hard and A≤pBA \le_p B with B∈B \in NP, then BB is NP-complete. The Cook-Levin Theorem establishes this hardness seed: SAT (and its restricted form 3-SAT, where every clause has exactly three literals) is NP-complete, because a nondeterministic Turing machine's computation can be encoded as a Boolean formula whose satisfying assignments correspond exactly to accepting computation histories. The strategy here is a two-step relay. First we reduce 3-SAT to Clique directly, translating the local structure of a 3-CNF formula (three literals per clause, at most one satisfied literal needed per clause, no two contradictory literals both true) into the local structure of a graph (edges represent "compatible," non-edges represent "conflicting" or "same clause"). Second, we show Clique and Vertex Cover are two views of the same combinatorial fact by passing to the graph complement — no simulation of computation is needed here, just a one-line algebraic identity relating cliques and covers.

How it works

Reduction 1: 3-SAT ≤p Clique. Let φ=C1∧C2∧⋯∧Ck\varphi = C_1 \wedge C_2 \wedge \cdots \wedge C_k be a 3-CNF formula with each clause Ci=(ℓi,1∨ℓi,2∨ℓi,3)C_i = (\ell_{i,1} \vee \ell_{i,2} \vee \ell_{i,3}), literals over variables x1,…,xnx_1, \dots, x_n. Build a graph GφG_\varphi as follows. ``` function REDUCE_3SAT_TO_CLIQUE(phi):

# phi has clauses C_1, ..., C_k, each with 3 literals V = {} for i in 1..k: for j in 1..3: create vertex v[i][j] labeled with literal l[i][j] add v[i][j] to V E = {} for i in 1..k: for j in 1..3: for i' in 1..k, i' != i: for j' in 1..3: l = label(v[i][j]) l' = label(v[i'][j']) if l is not the negation of l': add edge (v[i][j], v[i'][j']) to E G = (V, E) return (G, k) # ask: does G have a clique of size k? ``` Two vertices are connected exactly when they come from different clauses and their literals are not negations of each other (they might even be the same literal — that is fine, both can be true together). Vertices within the same clause are never connected, since a clause only needs one true literal, and we do not want to be forced to pick more than one vertex per clause.

Reduction 2: Clique ≤p Vertex Cover (and the reverse). The key fact is purely graph-theoretic and needs no gadget construction, only the notion of the complement graph Gˉ=(V,Eˉ)\bar{G} = (V, \bar{E}), where Eˉ\bar{E} contains exactly the pairs not in EE. ``` function REDUCE_CLIQUE_TO_VERTEX_COVER(G, k): n = |V(G)| Gbar = complement of G # (u,v) in Gbar iff (u,v) not in E(G) return (Gbar, n - k) # ask: does Gbar have a vertex cover of size n-k? ``` The same construction run in reverse (complementing again) reduces Vertex Cover to Clique, since Gˉ‾=G\overline{\bar{G}} = G and n−(n−k)=kn - (n-k) = k. So the two problems are polynomial-time equivalent, not just each reducible to the other.

Figure
3-SAT-to-Clique gadget: three clauses, one vertex per literal occurrence, edges join compatible literals from different clauses
φ = (x₁ ∨ x₂ ∨ ¬x₃) ∧ (¬x₁ ∨ x₂ ∨ x₃) ∧ (x₁ ∨ ¬x₂ ∨ x₃) clause C₁ x₁ x₂ ¬x₃ clause C₂ ¬x₁ x₂ x₃ clause C₃ x₁ ¬x₂ x₃ x₁ vs ¬x₁: no edge Green triangle = 3-clique = one true literal per clause = satisfying assignment x₁ = T, x₂ = T, x₃ = T satisfies all three clauses

The pseudocode and figure describe the forward direction (3-SAT to Clique); the size parameter kk is set to the number of clauses, since a clique must pick exactly one vertex per clause block (no two vertices in the same block are ever adjacent) to reach size kk.

Complexity & correctness

Membership in NP. Both Clique and Vertex Cover are in NP. A certificate for Clique is the subset CC of size kk; verification checks all (k2)\binom{k}{2} pairs for edges, which takes O(k2)O(k^2) time, polynomial in the input size. A certificate for Vertex Cover is the subset SS of size kk; verification scans every edge (at most O(n2)O(n^2) of them) and checks that at least one endpoint lies in SS, also polynomial.

Correctness of 3-SAT ≤p Clique. Let φ\varphi have kk clauses. We claim φ\varphi is satisfiable iff GφG_\varphi has a clique of size kk. (⇒\Rightarrow) Suppose assignment aa satisfies φ\varphi. Each clause CiC_i has at least one literal made true by aa; pick one such literal per clause and call its vertex viv_i. The set {v1,…,vk}\{v_1, \dots, v_k\} has exactly one vertex per clause block, so no two of them are in the same block. For any i≠i′i \ne i', the literals at viv_i and vi′v_{i'} are both true under aa, so they cannot be negations of each other (a variable and its negation cannot both be true). By construction there is therefore an edge between viv_i and vi′v_{i'}. Hence {v1,…,vk}\{v_1,\dots,v_k\} is a clique of size kk. (⇐\Leftarrow) Suppose GφG_\varphi has a clique CC of size kk. Since vertices within one clause block are pairwise non-adjacent, CC can contain at most one vertex from each of the kk blocks; having size kk forces exactly one vertex per block. Define an assignment aa: for each variable xx, if some vertex in CC is labeled xx, set x=truex = \text{true}; if some vertex in CC is labeled ¬x\neg x, set x=falsex = \text{false}; set unconstrained variables arbitrarily. This is well-defined because CC is a clique: if CC contained both an xx-vertex and a ¬x\neg x-vertex, they would (by construction) have no edge between them, contradicting that CC is a clique. Since every clause block contributes one vertex to CC, every clause has a literal set true by aa, so aa satisfies φ\varphi.

Polynomial-time computability of the reduction. GφG_\varphi has exactly 3k3k vertices and at most (3k2)=O(k2)\binom{3k}{2} = O(k^2) candidate edges, each checked in constant time against the negation condition. The whole construction runs in O(k2)O(k^2) time and produces an instance of size polynomial in ∣φ∣|\varphi|, satisfying the definition of a polynomial-time mapping reduction.

Correctness of Clique ↔ Vertex Cover. This rests on one identity: for any graph H=(V,E)H = (V,E) and subset S⊆VS \subseteq V,

S is a clique in H  ⟺  V∖S is a vertex cover of Hˉ.S \text{ is a clique in } H \iff V \setminus S \text{ is a vertex cover of } \bar H.

Proof. SS is a clique in HH means every pair u,v∈Su,v \in S satisfies (u,v)∈E(H)(u,v) \in E(H), equivalently (u,v)∉E(Hˉ)(u,v) \notin E(\bar H). So Hˉ\bar H has no edge with both endpoints in SS, meaning every edge of Hˉ\bar H has at least one endpoint outside SS, i.e. in V∖SV \setminus S. That is precisely the statement that V∖SV \setminus S covers every edge of Hˉ\bar H. Each step is reversible (an "iff" throughout), so the equivalence holds in both directions. ■\blacksquare Applying this with H=GH = G and ∣S∣=k|S| = k: GG has a kk-clique iff Gˉ\bar G has a vertex cover of size n−kn - k. This is exactly what the reduction computes, and running it on (Gˉ,n−k)(\bar G, n-k) recovers (G,k)(G, k), giving the reverse reduction for free. Complementing a graph takes O(n2)O(n^2) time (flip every possible pair's edge status), so the reduction is polynomial.

Complexity summary.

ProblemMembershipHardness sourceOverall class
3-SATNP (check assignment)The Cook-Levin TheoremNP-complete
CliqueNP (O(k2)O(k^2) check)3-SAT ≤p CliqueNP-complete
Vertex CoverNP (O(n2)O(n^2) check)Clique ≤p Vertex CoverNP-complete

Because NP-completeness only asserts no known polynomial algorithm and NP-hardness, best-known exact algorithms for both problems remain exponential in the worst case — brute force over all (nk)\binom{n}{k} subsets, or smarter branch-and-bound / treewidth-based methods that still blow up on adversarial graphs. Both problems do admit useful tradeoffs: Vertex Cover has a simple factor-2 polynomial-time approximation (repeatedly pick both endpoints of an uncovered edge), and a fixed-parameter-tractable algorithm running in O(1.2k⋅n)O(1.2^k \cdot n) time via kernelization, exponential only in the parameter kk, not in nn. Clique has no such approximation guarantee under standard complexity assumptions — approximating the maximum clique size within any polynomial factor is itself NP-hard, which is a notably harsher inapproximability landscape than Vertex Cover's.

Worked example

Take φ=(x1∨x2∨¬x3)∧(¬x1∨x2∨x3)∧(x1∨¬x2∨x3)\varphi = (x_1 \vee x_2 \vee \neg x_3) \wedge (\neg x_1 \vee x_2 \vee x_3) \wedge (x_1 \vee \neg x_2 \vee x_3), matching the figure. We build GφG_\varphi with 3×3=93 \times 3 = 9 vertices and ask for a clique of size k=3k = 3.

VertexClauseLiteral
v1,1v_{1,1}C1C_1x1x_1
v1,2v_{1,2}C1C_1x2x_2
v1,3v_{1,3}C1C_1¬x3\neg x_3
v2,1v_{2,1}C2C_2¬x1\neg x_1
v2,2v_{2,2}C2C_2x2x_2
v2,3v_{2,3}C2C_2x3x_3
v3,1v_{3,1}C3C_3x1x_1
v3,2v_{3,2}C3C_3¬x2\neg x_2
v3,3v_{3,3}C3C_3x3x_3

Try assignment x1=x2=x3=truex_1 = x_2 = x_3 = \text{true}. Check each clause: C1C_1 is satisfied by x1x_1 (or x2x_2), C2C_2 is satisfied by x2x_2 (or x3x_3), C3C_3 is satisfied by x1x_1 (or x3x_3). All three clauses are satisfied, so φ\varphi is satisfiable. Following the forward direction of the proof, pick one true literal's vertex per clause: v1,1v_{1,1} (x1x_1), v2,2v_{2,2} (x2x_2), v3,3v_{3,3} (x3x_3). Check pairwise edges:

  • v1,1v_{1,1} (x1x_1) and v2,2v_{2,2} (x2x_2): different clauses, and x2x_2 is not ¬x1\neg x_1, so edge exists.
  • v2,2v_{2,2} (x2x_2) and v3,3v_{3,3} (x3x_3): different clauses, x3x_3 is not ¬x2\neg x_2, so edge exists.
  • v1,1v_{1,1} (x1x_1) and v3,3v_{3,3} (x3x_3): different clauses, x3x_3 is not ¬x1\neg x_1, so edge exists.

All three pairs are adjacent, so {v1,1,v2,2,v3,3}\{v_{1,1}, v_{2,2}, v_{3,3}\} is a 3-clique, exactly as the reconstruction procedure claims — matching the green triangle in the figure. Now push this graph through the second reduction. With n=9n = 9 vertices and k=3k = 3, the Vertex Cover instance is (Gφˉ, 9−3=6)(\bar{G_\varphi},\, 9 - 3 = 6): does the complement graph have a vertex cover of size 6? By the equivalence proved above, V∖{v1,1,v2,2,v3,3}V \setminus \{v_{1,1}, v_{2,2}, v_{3,3}\} — the other 6 vertices — must be a vertex cover of Gφˉ\bar{G_\varphi}. Indeed: any edge of Gφˉ\bar{G_\varphi} is a non-edge of GφG_\varphi, and since {v1,1,v2,2,v3,3}\{v_{1,1},v_{2,2},v_{3,3}\} is a clique in GφG_\varphi (all pairs among them are edges in GφG_\varphi), no edge of Gφˉ\bar{G_\varphi} can have both endpoints in that triple — so every Gφˉ\bar{G_\varphi}-edge touches the remaining 6 vertices, confirming the cover.

Common pitfalls & traps

PitfallWhy it's wrongFix
Connecting literals within the same clause blockWould allow a clique to use two vertices from one clause, breaking the "exactly one true literal picked" correspondenceNever add edges between vertices of the same CiC_i
Treating "not a negation" as "must be identical"Two different literals over different variables are compatible even though unequal; only xx vs ¬x\neg x conflictsOnly exclude edges between a variable and its own negation
Forgetting kk = number of clauses (using number of variables instead)The clique size must match the number of blocks that must each contribute one vertexSet kk = clause count, always
Assuming Vertex Cover reduction needs a fresh gadgetIt's tempting to build literal/clause gadgets again from scratchReuse the complement-graph identity — no new construction needed
Confusing Vertex Cover's factor-2 approximability with Clique'sAssuming both problems have equally good approximation algorithmsVertex Cover has polynomial 2-approximation; Clique's approximability is far worse under standard assumptions

Pioneers & history

The classification of Clique and Vertex Cover as NP-complete traces back to the founding wave of complexity theory that formalized what it means for a problem to be "as hard as any problem checkable in polynomial time."

Origins · 1 minRichard M. Karp and how this was discovered
RM
Richard M. Karp
born 1935 · Karp's 1972 paper "Reducibility Among Combinatorial Problems" cataloged 21 NP-complete problems, including Clique and Vertex Cover, building directly on Cook's theorem to show these hardness proofs form a connected web rather than isolated results.

History
1971
— Stephen Cook proves SAT is NP-complete, giving the first anchor problem.
1972
— Richard Karp publishes reductions establishing 21 problems, including Clique and Vertex Cover, as NP-complete.
1973
— Leonid Levin independently publishes equivalent foundational hardness results in the Soviet Union.
1979
— Garey and Johnson's compendium systematizes NP-completeness proofs and popularizes standard reduction techniques.
2000
s — Fixed-parameter tractability and inapproximability results sharpen the practical picture for both problems.

Where this matters

Vertex Cover's structure appears directly in network monitoring: choosing the minimum set of routers or sensors so that every network link is observed by at least one endpoint is exactly a vertex cover instance, and the 2-approximation algorithm is used in practice when exact solutions are infeasible. Clique detection underpins social-network analysis (finding tightly-knit communities), bioinformatics (protein interaction clusters, where mutually-interacting proteins form cliques in interaction graphs), and computer vision (matching feature correspondences that must be mutually consistent). Scheduling systems that need to find the maximum set of pairwise-compatible tasks are solving Clique on a compatibility graph, and register allocation in compilers historically used graph-coloring formulations closely related to these problems. The reduction techniques themselves — building a gadget per clause and enforcing exactly-one-per-gadget selection — are reused throughout complexity theory, including in reductions to Hamiltonian Path and Circuit Problems, where similar "force exactly one choice per structural unit" gadgets encode computation into path-existence questions.

Ask the tutor: Can you show how the same clause-gadget technique extends to reduce 3-SAT directly to the Hamiltonian Path problem?

Why do we need two separate reductions instead of proving Vertex Cover NP-complete from 3-SAT directly?

You could construct a direct 3-SAT-to-Vertex-Cover gadget, and textbooks sometimes do. But once Clique is established as NP-complete, the complement-graph identity gives Vertex Cover's hardness "for free" in a single line, with no new gadget engineering required. This illustrates the real payoff of building an NP-completeness web: each new anchor problem shortens the proof burden for its neighbors. Choosing the shortest correct path — Clique first, then the complement trick — is standard practice and reflects how the field actually organizes these results rather than re-deriving everything from Turing machines each time.

Does the 3-SAT-to-Clique reduction work for general SAT, not just 3-CNF?

The same idea generalizes to CNF formulas with clauses of any size, though the classic reduction usually restricts to 3-CNF because 3-SAT is the version proved NP-complete directly from Cook-Levin via clause-arity reduction. With larger clauses, each block simply has more vertices (one per literal), and the same "different clause, non-negated" adjacency rule applies; the clique size still equals the number of clauses. The polynomial bound still holds since clause size is fixed or polynomially bounded relative to formula length.

Is there a graph where Clique is easy despite the general NP-completeness result?

Yes — NP-completeness is a worst-case statement, not a universal one. On graphs with special structure, such as perfect graphs, interval graphs, or bounded-treewidth graphs, maximum clique can be found in polynomial time using structural algorithms. Random sparse graphs also tend to have small maximum cliques found quickly by simple heuristics. NP-completeness only guarantees that some instances (constructed adversarially, e.g., from a hard 3-SAT formula) will resist all known efficient general-purpose algorithms.

How does the fixed-parameter-tractable algorithm for Vertex Cover avoid violating P ≠ NP intuitions?

The FPT algorithm runs in roughly O(1.2k⋅n)O(1.2^k \cdot n) time, where kk is the target cover size, not the number of vertices nn. When kk is small relative to nn (a common real-world case, since minimum vertex covers are often much smaller than the graph), this is fast in practice even though it's exponential in kk. It does not contradict NP-hardness because the exponential blowup is isolated to the parameter, and for large kk (potentially close to nn) the algorithm remains impractical, consistent with the worst-case hardness result.

What role does the reduction's polynomial running time play in the proof, beyond just "it's fast"?

Polynomial-time computability of the reduction function is essential, not incidental: it is exactly what allows a hypothetical polynomial-time algorithm for Clique to be composed with the reduction to yield a polynomial-time algorithm for 3-SAT. If the reduction itself took exponential time, a fast Clique algorithm would say nothing about 3-SAT's complexity. The composition (reduce, then solve) must stay polynomial overall, so each stage individually must be polynomial — this is the precise mechanical reason Polynomial-Time Mapping Reductions are defined the way they are.

Can the same complement trick be used to relate Vertex Cover to Independent Set?

Yes, and it's essentially the same identity viewed from a third angle: SS is an independent set in GG iff SS is a clique in Gˉ\bar G iff V∖SV \setminus S is a vertex cover of GG itself (no complement needed for this last equivalence, since independent set and vertex cover are complementary within the same graph). This gives a triangle of equivalences — Clique, Independent Set, Vertex Cover — all reducible to each other in polynomial time, with only one requiring a graph complement.

Why is Cook-Levin necessary before any of this, rather than proving Clique hard directly from Turing machines?

It's possible in principle to encode a Turing machine's computation directly into a Clique instance, but it would require re-deriving all the tableau-and-transition gadgetry that The Cook-Levin Theorem already built for SAT. Reusing 3-SAT as the anchor means every subsequent NP-completeness proof, including Clique's, only needs to translate logical structure (clauses, literals) into combinatorial structure (vertices, edges), which is a dramatically simpler translation than simulating a machine from scratch.

Before this

Where this leads