hamiltonian cycle 3 color circuit sat
play

Hamiltonian Cycle, 3-Color, Circuit-SAT Lecture 24 April 25, 2017 - PowerPoint PPT Presentation

CS 374: Algorithms & Models of Computation, Spring 2017 Hamiltonian Cycle, 3-Color, Circuit-SAT Lecture 24 April 25, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 58 Recap NP : languages that have non-deterministic polynomial


  1. CS 374: Algorithms & Models of Computation, Spring 2017 Hamiltonian Cycle, 3-Color, Circuit-SAT Lecture 24 April 25, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 58

  2. Recap NP : languages that have non-deterministic polynomial time algorithms Chandra Chekuri (UIUC) CS374 2 Spring 2017 2 / 58

  3. Recap NP : languages that have non-deterministic polynomial time algorithms A language L is NP-Complete iff L is in NP for every L ′ in NP , L ′ ≤ P L Chandra Chekuri (UIUC) CS374 2 Spring 2017 2 / 58

  4. Recap NP : languages that have non-deterministic polynomial time algorithms A language L is NP-Complete iff 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 . Chandra Chekuri (UIUC) CS374 2 Spring 2017 2 / 58

  5. Recap NP : languages that have non-deterministic polynomial time algorithms A language L is NP-Complete iff 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) SAT is NP-Complete . Chandra Chekuri (UIUC) CS374 2 Spring 2017 2 / 58

  6. Pictorial View NP-Hard NP-C NP P Chandra Chekuri (UIUC) CS374 3 Spring 2017 3 / 58

  7. P and NP Possible scenarios: P = NP . 1 P � = NP 2 Chandra Chekuri (UIUC) CS374 4 Spring 2017 4 / 58

  8. P and NP Possible scenarios: P = NP . 1 P � = NP 2 Question: Suppose P � = NP . Is every problem in NP \ P also NP-Complete ? Chandra Chekuri (UIUC) CS374 4 Spring 2017 4 / 58

  9. P and NP Possible scenarios: P = NP . 1 P � = NP 2 Question: Suppose P � = NP . Is every problem in NP \ P also NP-Complete ? Theorem (Ladner) If P � = NP then there is a problem/language X ∈ NP \ P such that X is not NP-Complete . Chandra Chekuri (UIUC) CS374 4 Spring 2017 4 / 58

  10. Today NP-Completeness of three problems: Hamiltonian Cycle 3 -Color Circuit SAT Important: understanding the problems and that they are hard. Proofs and reductions will be sketchy and mainly to give a flavor Chandra Chekuri (UIUC) CS374 5 Spring 2017 5 / 58

  11. Part I NP-Completeness of Hamiltonian Cycle Chandra Chekuri (UIUC) CS374 6 Spring 2017 6 / 58

  12. Directed Hamiltonian Cycle Input Given a directed graph G = ( V , E ) with n vertices Goal Does G have a Hamiltonian cycle? Chandra Chekuri (UIUC) CS374 7 Spring 2017 7 / 58

  13. 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 Chandra Chekuri (UIUC) CS374 7 Spring 2017 7 / 58

  14. Is the following graph Hamiltonianan? (A) Yes. (B) No. Chandra Chekuri (UIUC) CS374 8 Spring 2017 8 / 58

  15. Directed Hamiltonian Cycle is NP-Complete Directed Hamiltonian Cycle is in NP : exercise Hardness: We will show 3-SAT ≤ P Directed Hamiltonian Cycle Chandra Chekuri (UIUC) CS374 9 Spring 2017 9 / 58

  16. 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 . Chandra Chekuri (UIUC) CS374 10 Spring 2017 10 / 58

  17. 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. Chandra Chekuri (UIUC) CS374 11 Spring 2017 11 / 58

  18. The Reduction: Phase I Traverse path i from left to right iff 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 Chandra Chekuri (UIUC) CS374 12 Spring 2017 12 / 58

  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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  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 ”Buffer” vertices ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 x 1 x 2 x 3 x 4 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  22. 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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  23. 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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  24. 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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  25. 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 Chandra Chekuri (UIUC) CS374 13 Spring 2017 13 / 58

  26. Correctness Proof Proposition ϕ has a satisfying assignment iff G ϕ has a Hamiltonian cycle. Proof. ⇒ Let a be the satisfying assignment for ϕ . Define Hamiltonian cycle as follows If a ( x i ) = 1 then traverse path i from left to right If a ( 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 Chandra Chekuri (UIUC) CS374 14 Spring 2017 14 / 58

  27. Hamiltonian Cycle ⇒ Satisfying assignment 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 Chandra Chekuri (UIUC) CS374 15 Spring 2017 15 / 58

  28. Example x 1 x 2 x 3 x 4 Chandra Chekuri (UIUC) CS374 16 Spring 2017 16 / 58

  29. 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 Chandra Chekuri (UIUC) CS374 17 Spring 2017 17 / 58

  30. Hamiltonian Cycle Problem 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)? Chandra Chekuri (UIUC) CS374 18 Spring 2017 18 / 58

  31. 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 Chandra Chekuri (UIUC) CS374 19 Spring 2017 19 / 58

  32. Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ such that G has Hamiltonian Path iff G ′ has Hamiltonian path Reduction a c v b d Chandra Chekuri (UIUC) CS374 20 Spring 2017 20 / 58

  33. Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ such that G has Hamiltonian Path iff G ′ has Hamiltonian path Reduction Replace each vertex v by 3 vertices: v in , v , and v out a c v b d Chandra Chekuri (UIUC) CS374 20 Spring 2017 20 / 58

  34. Reduction Sketch Goal: Given directed graph G , need to construct undirected graph G ′ such that G has Hamiltonian Path iff 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 Chandra Chekuri (UIUC) CS374 20 Spring 2017 20 / 58

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