Download presentation

Presentation is loading. Please wait.

Published byKaila Warbington Modified about 1 year ago

1
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck

2
Before We have shown NP-completeness of 3-SAT: – a k-CNF is a CNF in which all clauses have 3 literals (or less) – k-SAT={set of all k-CNF that are satisfiable} Notes: Not hard to give a reduction from CNF-SAT to 3-SAT 2-SAT is in P (and hence not NP-complete unless P=NP) 3-SAT is the basis of our reductions from now on

3
Reductions We will show some reductions from 3-SAT to a few problems Due to transitivity we can use reductions from any of the problems for which we already have a reduction from 3-SAT – Often this is easier

4
Vertex Cover For an undirected Graph G a vertex cover is a subset S of the vertices such that every edge has at least one endpoint in S VC={G,k such that G has a vertex cover of size at most k} Theorem: VC is NP-complete Part 1: VC in NP is easy (guess S and check all edges)

5
Reduction VC Part 2: we reduce from 3-SAT Let F be a formula with variables x 1,…,x n and 3-clauses z 1,…,z m For each x i we use two vertices v i and w i connected by an edge (variable gadget) For each z i we use three vertices a i, b i, c i connected to form a triangle (clause gadget)

6
Reduction VC v i corresponds to the literal x i w i to the literal : x i We connect a i, b i, c i with the corresponding literal from clause z i We set k to n+2m Observation: For any vertex cover S one of v i and w i needs to be in S, and at least 2 of a i, b i, c i 1) Assume x satisfies F. We show that a small S exists. If x i =0 we choose w i else v i for S For each clause gadget at least one of a i, b i, c i is connected to a vertex in S. Choose other 2 vertices per clause gadget to form a VC of size n+2m

7
Reduction VC 2) Now assume there is a VC S of size at most k=n+2m S must contain either v i or w i S must contain two vertices for each clause gadget (triangle) Hence it cannot contain v i and w i Set x accordingly (x i =1 iff v i 2 S) Claim: this is a satisfying assignment Proof: every clause gadget must have one vertex not in S, connected to a literal node in S Hence x satisfies F

8
Clique We want to show that MaxClique is NP- complete – Surely it is in NP Reduction from VC Observation/reduction: (G,k) 2 VC iff (G c,n-k) 2 Max Clique – G c : complement of G

9
Observation If S is a vertex cover in G then all edges in G have one endpoint in S, there are no edges going from V-S to V-S Hence in the complement of G, V-S is a clique G c,n-k in MaxClique Note: we have shown that VC has a 2-approximation algorithm Max Clique does not have a n 1- ² approximation unless P=NP – Notice how a VC of size · 2k implies only a Clique of size ¸ n-2k, which can be much smaller than n-k, e.g., k=n/2

10
SetCover Input: set of m subsets s 1,…,s n of S, |S|=m Task: find the smallest set of s i such that S= [ i 2I s i We want | I | minimal SetCover:{s 1,…,s n,k: there is I µ {1,…,n}, | I |=k, [ i 2I s i = [ i=1…n s i } Theorem: SetCover is NP-complete – Part 1: 2 NP: guess I

11
SetCover Part 2: Reduction from VC G,k is mapped to a SetCover instance as follows: G=(V,E) Universe: E Subsets: s 1,…,s n s i : {edges adjacent to vertex i} k unchanged Then: (G,k) 2 VC iff (s 1,…,s n,k) 2 SetCover

12
Hamiltonian Cycle A Hamiltonian cycle in a directed G=(V,E) is a cycle that visits each vertex once HC={G: G has a Hamiltonian cycle} Theorem: HC is NP-complete In NP: guess the cycle Hardness: reduction from VC

13
HC G=(V,E) and k given (input to VC) Assume edges in E are ordered (e 1,…,e m ) New vertices: a 1,…,a k and vertices (u,e,b) where u 2 V, e 2 E is incident to u and b 2 {0,1} Edges: (u,e,0) to (u,e,1) type 1 (u,e,b) to (v,e,b) where e={u,v} type 2 (u,e,1) to (u,e’,0) where e,e’ inc. to u and there is no e’’ with e

14
HC Take vertex cover S of size k Find the cycle: for v 2 S consider all the vertices (v,e,b) and all (u,e,b) where e={u,v} We traverse these from (v,e,0) in ascending order of e – (v,e,0) to (v’,e,0) to (v’,e,1) to (v,e,1) to (v,e’,0) etc. until (v,e,1) for max e at v reached. Then to a 1 and to the next (u,e,0) with u the next vertex in S and e min. at u A Hamitonian cycle exists Assume a Hamiltonian cycle ex. It must traverse all a i. Group all vertices visited between a i and a i+1 Claim: vertex cover of size k exists

15
Traveling Salesman Input: matrix of distances (edge weights),k Output: is there a Hamiltonian cycle of total edge weight at most k? Reduction from HC: – Use adjacency matrix as weights, k=n

16
Subgraph Isomorphism Given G,H, is H isomorphic to a subgraph of G? – subgraph: subset of vertices and edges – isomorphic: same up to renaming vertices Theorem: Subgraph isomorphism is NP- complete Reduction from Clique: Map G,k to G and H, where H is a k-clique (undirected case) Reduction from HC: Map G to G and H, where H is an n-cycle (directed case)

17
Note Graph Isomorphism (are G,H isomorphic?) is not known to be in P or NPC

18
Subset Sum Input: set S of integers, target t Is there a subset S’ µ S such that the elements in S’ sum to t? Theorem: Subset Sum is NP-complete Reduction from 3-SAT

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google