Chapter 34: NP-Completeness

Similar documents
CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-completeness. Chapter 34. Sergey Bereg

NP-Complete Reductions 1

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

NP-Completeness. NP-Completeness 1

NP-Complete Problems. More reductions

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

1. Introduction Recap

Lecture 4: NP and computational intractability

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

NP-Complete problems

Introduction to Complexity Theory

Correctness of Dijkstra s algorithm

NP and Computational Intractability

Design and Analysis of Algorithms

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Introduction. Pvs.NPExample

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

1.1 P, NP, and NP-complete

NP-Complete Reductions 2

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Essential facts about NP-completeness:

Lecture 15 - NP Completeness 1

CS 583: Algorithms. NP Completeness Ch 34. Intractability

NP and Computational Intractability

Computational Intractability 2010/4/15. Lecture 2

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

SAT, Coloring, Hamiltonian Cycle, TSP

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Algorithm Design and Analysis

NP Complete Problems. COMP 215 Lecture 20

Polynomial-time reductions. We have seen several reductions:

Geometric Steiner Trees

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Spring Lecture 21 NP-Complete Problems

Lecture 18: More NP-Complete Problems

Polynomial-time Reductions

CMPT307: Complexity Classes: P and N P Week 13-1

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Algorithm Design and Analysis

Lecture #14: NP-Completeness (Chapter 34 Old Edition Chapter 36) Discussion here is from the old edition.

NP-problems continued

Theory of Computer Science. Theory of Computer Science. E4.1 Overview E4.2 3SAT. E4.3 Graph Problems. E4.4 Summary.

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

CS Fall 2011 P and NP Carola Wenk

Today: NP-Completeness (con t.)

Formal definition of P

NP-Completeness. Until now we have been designing algorithms for specific problems

Algorithms Design & Analysis. Approximation Algorithm

NP-problems continued

CS154, Lecture 15: Cook-Levin Theorem SAT, 3SAT

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

ECS122A Handout on NP-Completeness March 12, 2018

Data Structures and Algorithms (CSCI 340)

Discrete Optimization 2010 Lecture 10 P, N P, and N PCompleteness

VIII. NP-completeness

Introduction to Computational Complexity

More NP-Complete Problems

NP-Complete Problems. Complexity Class P. .. Cal Poly CSC 349: Design and Analyis of Algorithms Alexander Dekhtyar..

CS5371 Theory of Computation. Lecture 19: Complexity IV (More on NP, NP-Complete)

Lecture 25: Cook s Theorem (1997) Steven Skiena. skiena

NP-Completeness. Dr. B. S. Panda Professor, Department of Mathematics IIT Delhi, Hauz Khas, ND-16

CS/COE

SAT, NP, NP-Completeness

Theory of Computer Science. Theory of Computer Science. E5.1 Routing Problems. E5.2 Packing Problems. E5.3 Conclusion.

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Instructor N.Sadagopan Scribe: P.Renjith

NP-Completeness. Subhash Suri. May 15, 2018

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 22 Lecturer: David Wagner April 24, Notes 22 for CS 170

Una descrizione della Teoria della Complessità, e più in generale delle classi NP-complete, possono essere trovate in:

Lecture 18: PCP Theorem and Hardness of Approximation I

CSC 373: Algorithm Design and Analysis Lecture 15

Show that the following problems are NP-complete

Chapter 3: Proving NP-completeness Results

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

Lecture 13, Fall 04/05

Combinatorial Optimization

3130CIT Theory of Computation

More on NP and Reductions

Complexity, P and NP

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

CSE 105 THEORY OF COMPUTATION

NP-Complete Problems and Approximation Algorithms

NP Completeness and Approximation Algorithms

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

CS 350 Algorithms and Complexity

Chapter 2 : Time complexity

Polynomial-Time Reductions

Topics in Complexity Theory

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Transcription:

Graph Algorithms - Spring 2011 Set 17. Lecturer: Huilan Chang Reference: Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 2nd Edition, The MIT Press. Chapter 34: NP-Completeness 2. Polynomial-time verification Hamiltonian cycles (a) is hamiltonian (b) is nonhamiltonian. 1

A formal language of hamiltonian-cycle problem: HAM-CYCLE = { G : G is a hamiltonian graph}. Verification algorithms certificate Example: Suppose that a friend tells you that a given graph G is hamiltonian, and then offers to prove it by giving you the vertices in order along the hamiltonian cycle. It is to verify the proof by checking whether it is a permutation of V and whether each of the consecutive edges along the cycle actually exists in the graph. verification algorithm 2

A verification algorithm is a two-argument algorithm A, where one argument is an ordinary input string x and the other is a binary string y called a certificate. (A(x, y)) An algorithm A verifies a language L if for any string x L, there is a certificate y that A can use to prove that x L. Moreover, for any string x L, there must be no certificate proving that x L. The complexity class NP A language L belongs to NP if and only if there exist an algorithm A that verifies L in polynomial time. A language L belongs to NP if and only if there exist a two-input polynomial-time algorithm A and constant c such that 3

L = {x {0, 1}* : there exists a certificate y with y = O( x c ) such that A(x, y) = 1}. HAM-CYCLE NP. y is a list of vertices in the hamiltonian cycle of G and A( G, y) is to check whether consecutive edges along the cycle actually exists in G. If L P, then L NP. (Thus P NP.) Example: for the decision problem PATH and an instance G, u, v, k, y is a list of vertices in a shortest uv-path and A( G, u, v, k, y) is to sum the edge weights along y and check whether the summation is at most k. 4

P = NP? (unknown!) Does L NP imply L NP? co-np is the set of languages L such that So, HAM-CYCLE co-np. L NP implies L co-np. L NP. NP = co-np? ( L NP implies L NP??) (unknown!) P NP co-np. P = NP co-np? (unknown!) 5

Four possible scenarios: 6

3. NP-completeness and reducibility Reducibility A language L 1 is polynomial-time reducible to a language L 2, written L 1 P L 2, if there exists a polynomial-time computable function f : {0, 1}* {0,1}* such that for all x {0, 1}*, x L 1 if and only if f ( x) L2. Lemma 34.3 If L 1, L 2 {0,1}* are languages such that L 1 P L 2, then L 2 P implies L 1 P. 7

NP-completeness Definition: L is NP-hard if L P L for every L NP. Definition: A language L {0, 1}* is NP-complete if L NP, and L P L for every L NP. SAT was the first known NP-complete problem, as proved by Stephen Cook in 1971 (see Cook's theorem for the proof). Theorem 34.4 If any NP-complete problem is polynomial-time solvable, then P = NP. Equivalently, if any problem in NP is not polynomial-time solvable, then no NP-complete problem is polynomial-time solvable. 8

4. NP-completeness proofs In definition, L is NP-hard if L P L for every L NP. Lemma 34.8 If L is a language such that L P L for some L NPC, then L is NP-hard. Moreover, if L NP, then L NPC. In the celebrated Cook-Levin theorem (independently proved by Leonid Levin), Cook proved that the Boolean satisfiability problem is NP-complete. 9

In 1972, Richard Karp proved that several other problems were also NP-complete (see Karp's 21 NP-complete problems); thus there is a class of NP-complete problems. Since Cook's original results, thousands of other problems have been shown to be NP-complete by reductions from other problems previously shown to be NP-complete; many of these problems are collected in Garey and Johnson's 1979 book Computers and Intractability: A Guide to the Theory of NP-Completeness. List of NP-complete problems (Wiki): http://en.wikipedia.org/wiki/list_of_np-complete_problems 10

5. NP-complete problems on graph theory (from our textbook) 11

(The following provides the sketch of how to prove that a decision problem is NP-complete. Many details are omitted. Please refer to our textbook for complete proofs. ) The clique problem Definition: a clique is a complete subgraph of G. The clique problem is the optimization problem of finding a clique of maximum size in a graph. Its decision problem: whether a clique of a given size k exists in the graph. Theorem 34.11 The clique problem is NP-complete. 12

Proof ( CLIQUE NP) Certificate: the set V' V of vertices in the clique for G. Checking whether V' is a clique can be accomplished in polynomial time by checking whether, for each pair u, v V', the edge (u, v) belongs to E. (The clique problem is NP-hard by showing 3-CNF-SAT P CLIQUE.) An example says thousand words! Example: φ = (x 1 x 2 x 3 ) ( x 1 x 2 x 3 ) (x 1 x 2 x 3 ). We construct the corresponding graph G as follows. 13

A polynomial reduction: The input to 3-CNF-SAT can be transformed into input to CLIQUE in polynomial time. Suppose φ contains k clauses. φ is satisfied if and only if G has a clique of size k. 14

The vertex-cover problem A vertex cover of an undirected graph G = (V, E) is a subset V' V such that if (u, v) E, then u V' or v V'. The size of a vertex cover is the number of vertices in it. Example: the graph has a vertex cover {w, z} of size 2. The vertex-cover problem is to find a vertex cover of minimum size in a given graph. Its decision problem: determine whether a graph has a vertex cover of a given size k. 15

Theorem 34.12 The vertex-cover problem is NP-complete. Proof (VERTEX-COVER NP) Suppose we are given a graph G = (V, E) and an integer k. Certificate: the vertex cover V' V itself. The verification algorithm affirms that V' = k, and then it checks, for each edge (u, v) E, that u V' or v V'. This verification can be performed in polynomial time. (The vertex-cover problem is NP-hard by showing that CLIQUE P VERTEX-COVER) 16

A polynomial reduction: The input G, k to CLIQUE can be transformed into the input G, V -k to VERTEX-COVER in polynomial time, where G is the complement of G. G has a vertex cover of size k if and only if G has a clique of size V -k. The hamiltonian-cycle problem Theorem 34.13 The hamiltonian cycle problem is NP-complete. 17

Proof (HAM-CYCLE NP) Given a graph G = (V, E), our certificate is the sequence of V vertices that makes up the hamiltonian cycle. The verification algorithm checks that this sequence contains each vertex in V exactly once and that there is an edge between each pair of consecutive vertices and between the first and last vertices. This verification can be performed in polynomial time. (VERTEX-COVER P HAM-CYCLE, which shows that HAM-CYCLE is NP-hard.) Given an undirected graph G = (V, E) and an integer k, we construct an undirected graph G' = (V', E') that has a 18

hamiltonian cycle if and only if G has a vertex cover of size k. G' is constructed according to steps1-3. Step1: An edge (u, v) of graph G corresponds to widget W uv in the graph G' created in the reduction. (a) The widget, with individual vertices labeled. 19

(b)-(d) The shaded paths are the only possible ones through the widget that include all vertices, assuming that the only connections from the widget to the remainder of G' are through vertices [u, v, 1], [u, v, 6], [v, u, 1], and [v, u, 6]. 20

Neighbors of w are ordered as xyz. Neighbors of x are ordered as wy. Neighbors of y are ordered as xw. 21

Step 2: The only other vertices in V' other than those of widgets are selector vertices s 1, s 2,..., s k. Step 3: In addition to the edges in widgets, there are two other types of edges in E'. First, for each vertex u V, we arbitrarily order the vertices adjacent to each vertex u V as u (1), u (2),..., u (degree(u)) and then add to E' the edges {([u, u (i), 6], [u, u (i+1), 1]) : 1 i degree(u) - 1}. 22

Second, we include the edges {(s j, [u, u (1), 1]) : u V and 1 j k} {(s j, [u, u (degree(u)), 6]) : u V and 1 j k}. The transformation from graph G to G' is a reduction: The input G, k to VERTEX-COVER can be transformed into the input G' to HAM-CYCLE in polynomial time. G as a vertex cover of size k if and only if G' has a hamiltonian cycle. (1) Suppose that G = (V, E) has a vertex cover V* = {u 1, u 2,..., u k }. A hamiltonian cycle in G is as 23

(1) (deg( u )) s [ u, u,1] [ u, u 1,6] s 1 2 1 1 (1) (deg( u )) [ u, u,1] [ u, u 2,6] 2 2 M 1 2 1 2 s k ( 1) (deg( uk )) [ u, u,1] [ u, u,6] k k k k (2) Suppose that G' = (V', E') has a hamiltonian cycle C E'. We claim that (1) V* = { u V : ( s j,[ u, u,1]) C for some 1 j k} is a vertex cover. 24

Key observation: partition C into maximal paths, called cover path as s i [u, u (1), 1] s j, without passing through any other selector vertex. Each cover path must start at some s i, take the edge (s i, [u, u (1), 1]) for some vertex u V, pass through all the widgets corresponding to edges in E incident on u, and then end at some selector vertex s j. Each vertex in each widget is visited by some cover path, we see that each edge in E is covered by some vertex in V*. 25

The traveling-salesman problem The traveling-salesman problem: given a complete graph where each edge has an integer cost, the salesman wishes to find a hamiltonian cycle of minimum cost. The following example has a minimum-cost tour u, w, v, x, u, with cost 7. 26

Theorem 34.14 The traveling-salesman problem is NP-complete. Proof (TSP NP) Given an instance G, k of the problem, we use as a certificate the sequence of n vertices in the tour. The verification algorithm checks that this sequence contains each vertex exactly once, sums up the edge costs, and checks whether the sum is at most k. This process can certainly be done in polynomial time. (TSP is NP-hard since HAM-CYCLE P TSP). Let G = (V, E) be an instance of HAM-CYCLE. We 27

construct an instance of TSP as follows. We form the complete graph G' = (V, E'), where E' = {(i, j) : i, j V and i j}, and we define the cost function c by 0 if ( i, j) E, c ( i, j) = 1 if ( i, j) E. The instance of TSP is then (G', c, 0), which is easily formed in polynomial time. G has a hamiltonian cycle if and only if graph G' has a tour of cost at most 0. 28