Presentation is loading. Please wait.

Presentation is loading. Please wait.

More NP-complete problems

Similar presentations


Presentation on theme: "More NP-complete problems"— Presentation transcript:

1 More NP-complete problems
So far we have studied three problems involving satisfiability We will use 3-CNF-SAT to prove clique, vertex-cover, and subset-sum are NP-complete We also will use 3-CNF-SAT to prove our hamiltonian cycle problem and the traveling salesman problem are NP-complete This style of “proof” using reducibility is common with NP-complete problems

2 The Clique Problem Problem statement A naïve approach
a clique is a set of vertices that form a connected subgraph of a given undirected graph the clique problem is to find a clique of maximum size as a decision problem we ask if a clique of size k exists A naïve approach given k, form all possible subsets of k vertices and test the complexity would be k is proportional to V, so this approach is superpolynomial

3 The Reduction Algorithm
We need to show 3-CNF-SAT <=p CLIQUE for each clause we place a triple of vertices in V we put an edge between if r  s and the literals are consistent this graph can be computed in polynomial time a satisfying assignment and a clique suppose the 3-sat problem has a satisfying assignment then at least one literal per term is assigned 1 picking each true literal in every clause produces a clique in the graph

4 An Example The vertices corresponding to the true items in each 3 tuple are white above, the others are shaded these white vertices form a clique conversely, given the clique x3 and x2 both true then (0,0,1) or (1,0,1) satisfy the equation

5 The Vertex-cover Problem
Problem statement a vertex cover of an undirected graph is a set of vertices V’ V such that if (u,v)  G then either u  V’ or v  V’ or both the vertex cover problem is to find the smallest subset that covers an undirected graph it is straightforward to show verification is polynomial we need to show CLIQUE <=p VERTEX-COVER the fundamental idea is to use the complement of a graph, that is, a graph with the same vertices but the set of edges complemented

6 The Reduction Algorithm
(a) contains the clique V’ = {u,v,x,y} (b) is the complement graph where V - V’ = {w,z} is a vertex cover for the graph the proof is completed by showing that G has a clique of size k iff the complement of G has a vertex cover of size |V| - k

7 The Subset-sum Problem
Problem statement given the set S = {s1, s2, s3, … sn } of positive integers and t, is there a subset of S that adds up to t verification for a given subset is easy we must show VERTEX-COVER <=p SUBSET-SUM the heart of the reduction is to use the incidence matrix |V| x |E| for the graph G = (V, E) an example construction is shown; the details of showing that G has a vertex cover of size k iff there is a subset S’ whose sum is t are given in the text

8 In (a) the vertex cover is {v1,v3,v4}; (b) shows the corresponding rows of the incidence matrix
In (c) we embed the matrix in rows x0 through x4 with a leading one; rows y0 through y4 are the base-4 numbers 1, 4, 16, 64, 256; the same xi are included as the vi and all yi are included except those corresponding the edges incident on two vertices in the vertex cover (y1 in this case) The Reduction

9 The Hamiltonian Cycle Problem
This reduction is complex and is based on “widgets” This is an A widget Any hamiltonian cycle must go through the zi in one of two ways as shown in (b) and (c) We treat an A widget as a simple pair of edges (a, a’) and (b, b’) with the restriction that any hamiltonian cycle must contain exactly one of these edges We will draw an A widget as shown in (d)

10 B Widget b1, b2, b3, b4 are the only vertices connecting to G
(a)-(e) show five possible traversals two others are possible by flipping (b) and (e) drawing (f) indicates at least one of the paths pointed to by B must be taken

11 The graph induced by a formula
The satisfying assignment s(x1) = 0, s(x2) = 1, s(x3) = 1corresponds to the hamiltonian cycle shown if s(xm) = 1 then the edge em is in the cycle; if s(xm) = 0 then not(em) is included

12 Some of the Details

13 The Traveling Salesman Problem
The problem a salesman must visit n cities, each exactly once and go back to the start each edge has a cost and the goal is to find the tour with minimum cost The verification part is easy: make sure all edges are in the graph and their sum is at most k

14 Showing HAM-CYCLE <=p TSP
Let G = (V,E) be hamiltonian we form G’ = (V, E’) where E’ = {(i, j): i, j  V} and the cost is this is easily done in polynomial time Claim: G has a hamiltonian cycle iff G’ has a tour of cost 0 if G has hamitonian cycle h, then each edge in G’ has cost 0, by definition, so a tour of total cost 0 exists if G’ has a tour of total cost at most 0, but edges are either 0 or 1, so the total cost must be exactly 0 so h’ only contains edges from E in G, so h is also a hamiltonian cycle for graph G


Download ppt "More NP-complete problems"

Similar presentations


Ads by Google