more np complete problems
play

More NP-Complete Problems Lecture 4 September 5, 2013 Sariel - PowerPoint PPT Presentation

CS 573: Algorithms, Fall 2013 More NP-Complete Problems Lecture 4 September 5, 2013 Sariel (UIUC) CS573 1 Fall 2013 1 / 48 Recap NP : languages that have polynomial time certifiers/verifiers. A language L is NP-Complete L is in NP


  1. CS 573: Algorithms, Fall 2013 More NP-Complete Problems Lecture 4 September 5, 2013 Sariel (UIUC) CS573 1 Fall 2013 1 / 48

  2. Recap NP : languages that have polynomial time certifiers/verifiers. A language L is NP-Complete ⇐ ⇒ L is in NP for every L ′ in NP , L ′ ≤ P L L is NP-Hard if for every L ′ in NP , L ′ ≤ P L . . Theorem (Cook-Levin) . Circuit-SAT and SAT are NP-Complete . . Sariel (UIUC) CS573 2 Fall 2013 2 / 48

  3. Recap NP : languages that have polynomial time certifiers/verifiers. A language L is NP-Complete ⇐ ⇒ L is in NP for every L ′ in NP , L ′ ≤ P L L is NP-Hard if for every L ′ in NP , L ′ ≤ P L . . Theorem (Cook-Levin) . Circuit-SAT and SAT are NP-Complete . . Sariel (UIUC) CS573 2 Fall 2013 2 / 48

  4. Recap NP : languages that have polynomial time certifiers/verifiers. A language L is NP-Complete ⇐ ⇒ L is in NP for every L ′ in NP , L ′ ≤ P L L is NP-Hard if for every L ′ in NP , L ′ ≤ P L . . Theorem (Cook-Levin) . Circuit-SAT and SAT are NP-Complete . . Sariel (UIUC) CS573 2 Fall 2013 2 / 48

  5. Recap NP : languages that have polynomial time certifiers/verifiers. A language L is NP-Complete ⇐ ⇒ L is in NP for every L ′ in NP , L ′ ≤ P L L is NP-Hard if for every L ′ in NP , L ′ ≤ P L . . Theorem (Cook-Levin) . Circuit-SAT and SAT are NP-Complete . . Sariel (UIUC) CS573 2 Fall 2013 2 / 48

  6. Recap contd . Theorem (Cook-Levin) . Circuit-SAT and SAT are NP-Complete . . Establish NP-Complete ness via reductions: SAT ≤ P 3-SAT and hence 3-SAT is NP -complete 3-SAT ≤ P Independent Set (which is in NP ) and hence Independent Set is NP-Complete Vertex Cover is NP-Complete Clique is NP-Complete Set Cover is NP-Complete Sariel (UIUC) CS573 3 Fall 2013 3 / 48

  7. Today Prove Hamiltonian Cycle Problem is NP-Complete . 3-Coloring is NP-Complete . Subset Sum . Sariel (UIUC) CS573 4 Fall 2013 4 / 48

  8. Part I . NP-Completeness of Hamiltonian Cycle . Sariel (UIUC) CS573 5 Fall 2013 5 / 48

  9. Directed Hamiltonian Cycle Input Given a directed graph G = ( V , E ) with n vertices Goal Does G have a Hamiltonian cycle? A Hamiltonian cycle is a cycle in the graph that visits every vertex in G exactly once Sariel (UIUC) CS573 6 Fall 2013 6 / 48

  10. Directed Hamiltonian Cycle Input Given a directed graph G = ( V , E ) with n vertices Goal Does G have a Hamiltonian cycle? A Hamiltonian cycle is a cycle in the graph that visits every vertex in G exactly once Sariel (UIUC) CS573 6 Fall 2013 6 / 48

  11. Directed Hamiltonian Cycle is NP-Complete Directed Hamiltonian Cycle is in NP Certificate: Sequence of vertices Certifier: Check if every vertex (except the first) appears exactly once, and that consecutive vertices are connected by a directed edge Hardness: We will show 3-SAT ≤ P Directed Hamiltonian Cycle Sariel (UIUC) CS573 7 Fall 2013 7 / 48

  12. Reduction Given 3-SAT formula φ create a graph G φ such that G φ has a Hamiltonian cycle if and only if φ is satisfiable G φ should be constructible from φ by a polynomial time algorithm A Notation: φ has n variables x 1 , x 2 , . . . , x n and m clauses C 1 , C 2 , . . . , C m . Sariel (UIUC) CS573 8 Fall 2013 8 / 48

  13. Reduction: First Ideas Viewing SAT: Assign values to n variables, and each clauses has 3 ways in which it can be satisfied. Construct graph with 2 n Hamiltonian cycles, where each cycle corresponds to some boolean assignment. Then add more graph structure to encode constraints on assignments imposed by the clauses. Sariel (UIUC) CS573 9 Fall 2013 9 / 48

  14. The Reduction: Phase I Traverse path i from left to right if and only if x i is set to true. Each path has 3( m + 1) nodes where m is number of clauses in φ ; nodes numbered from left to right ( 1 to 3 m + 3 ) x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 10 Fall 2013 10 / 48

  15. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  16. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  17. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ”Buffer” vertices ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  18. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  19. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  20. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  21. The Reduction: Phase II Add vertex c j for clause C j . c j has edge from vertex 3 j and to vertex 3 j + 1 on path i if x i appears in clause C j , and has edge from vertex 3 j + 1 and to vertex 3 j if ¬ x i appears in C j . x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 11 Fall 2013 11 / 48

  22. Correctness Proof . Proposition . φ has a satisfying assignment ⇐ ⇒ G φ has a Hamiltonian cycle. . . Proof. . ⇒ Let α be the satisfying assignment for φ . Define Hamiltonian cycle as follows If α ( x i ) = 1 then traverse path i from left to right If α ( x i ) = 0 then traverse path i from right to left. For each clause, path of at least one variable is in the “right” direction to splice in the node corresponding to clause. . Sariel (UIUC) CS573 12 Fall 2013 12 / 48

  23. Hamiltonian Cycle ⇒ Satisfying assignment . Proof continued . Suppose Π is a Hamiltonian cycle in G φ If Π enters c j (vertex for clause C j ) from vertex 3 j on path i then it must leave the clause vertex on edge to 3 j + 1 on the same path i If not, then only unvisited neighbor of 3 j + 1 on path i is 3 j + 2 Thus, we don’t have two unvisited neighbors (one to enter from, and the other to leave) to have a Hamiltonian Cycle Similarly, if Π enters c j from vertex 3 j + 1 on path i then it must leave the clause vertex c j on edge to 3 j on path i . Sariel (UIUC) CS573 13 Fall 2013 13 / 48

  24. Example x 1 ∨ ¬ x 2 ∨ x 4 ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Sariel (UIUC) CS573 14 Fall 2013 14 / 48

  25. Hamiltonian Cycle = ⇒ Satisfying assignment (contd) Thus, vertices visited immediately before and after C i are connected by an edge We can remove c j from cycle, and get Hamiltonian cycle in G − c j Consider Hamiltonian cycle in G − { c 1 , . . . c m } ; it traverses each path in only one direction, which determines the truth assignment Sariel (UIUC) CS573 15 Fall 2013 15 / 48

  26. (Undirected) Hamiltonian Cycle . Problem ( Undirected Hamiltonian Cycle ) . Input: Given undirected graph G = ( V , E ) . Goal: Does G have a Hamiltonian cycle? That is, is there a cycle that visits every vertex exactly one (except start and end vertex)? . Sariel (UIUC) CS573 16 Fall 2013 16 / 48

  27. NP -Completeness . Theorem . Hamiltonian cycle problem for undirected graphs is NP-Complete . . . Proof. . The problem is in NP ; proof left as exercise. Hardness proved by reducing Directed Hamiltonian Cycle to this problem. . Sariel (UIUC) CS573 17 Fall 2013 17 / 48

  28. Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ such that G has Hamiltonian Path if and only if G ′ has Hamiltonian path . Reduction . Replace each vertex v by 3 vertices: v in , v , and v out A directed edge ( a , b ) is replaced by edge ( a out , b in ) a c v b d . Sariel (UIUC) CS573 18 Fall 2013 18 / 48

  29. Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ such that G has Hamiltonian Path if and only if G ′ has Hamiltonian path . Reduction . Replace each vertex v by 3 vertices: v in , v , and v out A directed edge ( a , b ) is replaced by edge ( a out , b in ) a c v b d . Sariel (UIUC) CS573 18 Fall 2013 18 / 48

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend