advertisement

Homework #30 sample solution: 9-10 edges? Problem: Dense Subgraph Input: A graph G, and integers k and y. Output: Does G contain a subgraph with exactly k vertices and at least y To prove Dense Subgraph is NP-complete, we show that Dense Subgraph is in NP and is NP-hard by reducing CLIQUE problem to Dense Subgraph. Dense Subgraph is NP: the polynomial time verifier will take (G, k, y) and H = (V’, E’) as certificate and check if H is a subgraph of G, |V’| = k, |E’| >= y. Dense Subgraph is NP-hard: We reduce the known NP-complete problem CLIQUE to it. Problem: CLIQUE Input: A undirected graph G = (V, E) and integer k. Output: Is there a clique of G containing exactly k vertices? Reduction: For an instance (G, k) of CLIQUE, where G=(V, E), we construct an instance of Dense Subgraph (G, k, k(k-1)/2) in constant time. Claim: G has a clique of size k iff G has a subgraph of k vertices and k(k-1)/2 edges. Proof of the claim: If there exists a clique of k vertices, that clique is a subgraph of k nodes and k(k-1)/2 edges. If we have a subgraph of k nodes and k(k-1)/2 edges, that subgraph must be a clique. 9-13 Problem: Hitting Set Input: A collection C of subsets of a set S, positive integer k. Output: Does S contain a subset S' such that S¢ £ k and each subset in C contains at least one element from S'? To prove hitting set is NP-complete, we will show that Hitting Set is in NP and is NP-hard by reducing the Vertex Cover problem to Hitting Set. Hitting Set is in NP: The polynomial time verifier will take (S, C, k) and H as certificate. The algorithm will check if (a) |H| = k; (b) H is a subset of S; (c) for every set X of C, X and H have at least one common element. The time complexity is O(|S|2|C|). Hitting Set is NP-hard because we can reduce the known NP-complete problem, Vertex Cover, to Hitting Set. Problem: vertex cover Input: A graph G = (V, E) and an integer k <= |V|. Output: Is there a subset S of at most k vertices such that every edge in E has at least one vertex in S? Reduction: Given a graph G = (V,E) and a number k, we define the instance (S, C, k) of Hitting Set as follows: k = k, S = V and C = { {u, v} | (u, v) in E }. The construction of (S, C, k) takes linear time. Claim: G has a vertex cover of size k iff (V, C, k) has a hitting set of size k. Proof of the claim: (Only if part): If G has a vertex cover X of size k, then X is also a hitting set for (V, C, k) because for each edge (u, v) of E, either u or v is in X. So for each set {u, v} of C, {u, v} has at least one element in X. Thus X is a hitting set. (If part): If X is a hitting set of (S, C, k), then X is also a vertex cover of G because for each set {u, v} of C, u or v is in X, so the edge {u, v} is covered by X.