🔗 NPC Reduction Visualizer

Interactive step-by-step demonstrations of classic polynomial-time reductions between NP-complete problems

3-SAT → Clique REDUCTION O(n² · m²)

Transform a 3-SAT formula into a graph such that the formula is satisfiable ⟺ the graph has a k-clique (k = number of clauses).

3-SAT Instance φ Graph G, integer k

Clique ↔ Independent Set EQUIVALENCE O(|V|²)

G has a clique of size k ⟺ complement graph Ḡ has an independent set of size k. The reduction simply flips all edges.

Clique in G Independent Set in Ḡ
Side-by-side comparison: The green vertices form a clique in G (left) — every pair is connected. In the complement Ḡ (right), those same vertices form an independent set — no edges between them. Edges are flipped: present in G ↔ absent in Ḡ.
Key Idea: • Complement graph Ḡ has the same vertices   • Edge in G → no edge in Ḡ, and vice versa   • All connected (clique) in G → none connected (independent set) in Ḡ   • Reduction cost: O(|V|²) to build Ḡ — polynomial ✓

Original Graph G — Clique highlighted

Complement Graph Ḡ — Independent Set highlighted

Independent Set ↔ Vertex Cover COMPLEMENT O(1)

S is an independent set ⟺ V \ S is a vertex cover. No graph modification needed — just complement the vertex selection.

Independent Set S Vertex Cover V \ S
Click vertices on either graph to toggle selection. The other graph auto-shows the complement.
Left: Green vertices = selected set S. Checked as Independent Set (no edge between green vertices).
Right: Orange vertices = V \ S (complement). Checked as Vertex Cover (every edge touches ≥1 orange vertex).
Toggle vertices on either side to explore the duality.

Independent Set view — S

Vertex Cover view — V \ S

3-SAT → Subset Sum REDUCTION O(n · m)

Encode a 3-SAT formula as a set of decimal numbers. Each digit position represents a variable or a clause. Formula is satisfiable ⟺ a subset sums to target T.

3-SAT Instance φ Set S, target T

3-SAT → 3-Coloring REDUCTION O(n + m)

Build a graph with variable gadgets and clause gadgets. The graph is 3-colorable ⟺ the formula is satisfiable.

3-SAT Instance φ Graph G (3-colorable?)
True (T)
False (F)
Base (B)
Uncolored