1 / 8

An NP-completeness Example

An NP-completeness Example. The graph CLIQUE problem. Undirected Graph G = (V, E) a clique is a complete subgraph of G Subset V’ of vertices that are all connected to each other CLIQUE = {(G,k) : G is a graph with a clique of size k}

oshin
Download Presentation

An NP-completeness Example

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An NP-completeness Example

  2. The graph CLIQUE problem • Undirected Graph G = (V, E) • a cliqueis a complete subgraph of G • Subset V’ of vertices that are all connected to each other • CLIQUE = {(G,k) : G is a graph with a clique of size k} • For a general graph, and large-enough |V|, k, straightforward (naïve) algorithm for CLIQUE takes factorial time • OMEGA(k2 * C(|V|, k) ) • 1. CLIQUE is in NP • Exercise: Given encoding of G, and a certificate V’, come up with a poly-time verification algorithm to check that V’ is a clique of size k for G • 2. CLIQUE is NP-hard • 3-CNF-SAT P CLIQUE • 1 + 2 implies CLIQUE is NP-complete

  3. CLIQUE is NP-hard 3-CNF-SAT P CLIQUE • From instance I_3_CNF_SAT of 3-CNF-SAT, generate an instance I_CLIQUE of CLIQUE in polynomial time • I_CLIQUE returns true exactly whenever I_3_CNF_SAT returns true • I_CLIQUE includes a graph G = (V, E) and a vertex subset V’ • Build the graph G to do the mapping • I_CLIQUE •  = C1 AND C2 AND … Ck • C1 = lit_11 OR lit_12 OR lit_13. • Lit_11 = x or NOT x • Similarly for C2, C3, … Ck • Build Graph G = (V, E) as follows • Take the r-th clause in I_3_CNF_SAT • For lit_1r OR lit_2r OR lit_3r, place vertices vert_1r, vert_2r, vert_3r in V • put an edge from vertices vert_ir to vert_js (i = 1, 2, 3; j = 1, 2, 3) if • r != s (I.e., the vertices correspond to different triples in the formula) AND • lit_ir != NOT lit_js • don’t put an edge from x to (NOT x) even if they are in different triples • CAN DO THIS IN POLY TIME!

  4.  = (x1 OR (NOT x2) OR (NOT x3)) AND ((NOT x1) OR x2 OR x3) AND (x1 OR x2 OR x3) true when x2 =0 and x3 = 1 • GRAPH (Fig 34.14) HERE • Suppose  is TRUE for some values of the variables. • Then each Cr is true => at least one of lit_r1, lit_r2, lit_r3 is true. • Select one such “true” vertex from each Cr (e.g., if lit_r2 and lit_r3 are both true, select vert_r2 at random from vert_r2 and vert_r3) • Call this a subset V’ • V’ has k elements (one from each Cr) and is a clique • Take any two vertices in V’, and there is an edge between them by construction. • By the selection method, they are in different triples • They are both 1’s by selection method, so they are not negations of each other. • We mapped from a satisfying assignment for  to a graph with a clique of size k (vert_12, vert_23, vert_33) • Suppose G has a clique V’ of size k (vert_12, vert_23, vert_33) • Each vertex in V’ belongs to a different triple and cover all triples between them • there cannot be an edge in G if two vertices belong to the same triple. • If vert_ri is in V’, assign lit_ri = 1 • there cannot be an assignment like { xi = 1; (NOT xi) =1 } • there cannot be an edge in G if two vertices are negations of each other • Each clause has one TRUE literal by the mapping • We mapped from a graph with clique of size k to a satisfying assignment for 

  5. CLIQUE is NP hard for the “special” kind of graphs • CLIQUE is “harder” for general kind of graph • CLIQUE is NP-hard for general kind of graph. • CLIQUE IS NP-COMPLETE.

  6. VERTEX COVER • Vertex cover of an undirected graph G = (V, E) is a subset V’ of V such that • if (u, v) is in E, then either u or v or both is in V’ • The vertices in V’ together ‘cover’ all the edges of E • |V’| is the size of a vertex cover. • VERTEX_COVER = { (G, k) : graph G has a vertex cover of size k}. • VERTEX_COVER is NP-complete • VERTEX_COVER is in NP • exercise given (G, k) and certificate c = V’, find a poly algorithm to verify c • VERTEX_COVER is NP-hard • CLIQUE p VERTEX_COVER

  7. Complement of a graph • COMP_G = (V, COMP_E) • COMP_E = { (u, v) : u, v are in V, u != v, and (u, v) not in E } • edges that are not in E • FIG 34.15 HERE • Reduction algorithm from CLIQUE to VERTEX_COVER • from I_CLIQUE = (G, k) Compute COMP_G (poly) • Claim: we now have I_VERTEX_COVER = (COMP_G, |V| - k) • G has a clique of size k if and only if COMP_G has a vertex cover of size |V| - k

  8. If part: • Suppose G has a clique V’ of size k. • Claim: V-V’ is a vertex cover in COMP_G • proof: suppose (u, v) is an edge in COMP_E. • Then (u, v) is not in E • So, either u or v is not in V’ since if both u and v are in V’, there must be an edge between them. • That is, either u or v is in V-V’ • if (u, v) is an edge in COMP_E, then V-V’ covers that edge, hence V-V’ is a vertex cover in COMP_G. and V-V’ has size |V| -k • Only-if part: • Suppose COMP_G has a vertex cover V’ of size |V| -k • claim: V-V’ is a clique in G • proof: for all u, v in V, if (u, v) is in COMP_E, then u is in V’ or v is in V’ or both • by contrapositive, for all u, v in V, if u is not in V’ and v is not in V’, then (u, v) is in E. • I.e., V-V’ is a clique.

More Related