CS 758/858: Algorithms http://www.cs.unh.edu/~ruml/cs758 Graph Problems Number Problem Wheeler Ruml (UNH) Class 22, CS 758 – 1 / 13
Graph Problems ■ Reductions ■ Clique ■ Vertex Cover ■ Break Number Problem Reductions to Graph Problems Wheeler Ruml (UNH) Class 22, CS 758 – 2 / 13
Reductions CIRCUIT-SAT Graph Problems ■ Reductions ■ Clique SAT ■ Vertex Cover ■ Break Number Problem 3-CNF SAT CLIQUE SUBSET-SUM VERTEX-COVER HAM-CYCLE TSP Wheeler Ruml (UNH) Class 22, CS 758 – 3 / 13
Clique Does graph have clique of size k ? Graph Problems ■ Reductions ■ Clique CLIQUE ∈ NP: given clique, test connectivity ( k 2 time). ■ Vertex Cover ■ Break Number Problem CLIQUE is NP-Hard: Reduction from 3-CNF SAT! Formula φ with k clauses will be SAT iff graph G has a k clique. For clause r like ( l r 1 ∨ l r 2 ∨ l r 3 ) , add vertices v r 1 , v r 2 , and v r 3 to G . Add edge from v r i to v s j iff r � = s and l r i � = ¬ l s j . SAT ⇒ clique: If φ SAT, at least one literal in each clause is true. These form a clique in G because they cannot conflict. Clique ⇒ SAT: If k clique, make corresponding literals true. Will satisfy all k clauses without conflicts. Example: ( x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) ∧ ( ¬ x 1 ∨ x 2 ∨ x 3 ) ∧ ( x 1 ∨ x 2 ∨ x 3 ) Wheeler Ruml (UNH) Class 22, CS 758 – 4 / 13
Vertex Cover Does graph have a vertex cover of size k ? Graph Problems ■ Reductions ■ Clique VERTEX-COVER ∈ NP: given cover, check size and that each ■ Vertex Cover ■ Break edge is covered. Number Problem VERTEX-COVER is NP-Hard: Reduction from CLIQUE. Form graph complement G , which has edge ( u, v ) for v � = u iff original does not. Claim: G has k clique iff G has | V | − k cover. Cover ⇒ clique: All edges in E have at least one endpoint in Cover . All pairs ( u, v ) with both u and v �∈ Cover therefore have edge ∈ E . So V − Cover is a clique of size k . Clique ⇒ cover: Any edge ( u, v ) ∈ E implies �∈ E implies u or v not in Clique . This implies u or v remains in V − Clique and hence it covers that edge. Size of V − Clique is | V | − k . Wheeler Ruml (UNH) Class 22, CS 758 – 5 / 13
Break asst 12 ■ Graph Problems final ■ Reductions ■ ■ Clique ■ Vertex Cover ■ Break Number Problem Wheeler Ruml (UNH) Class 22, CS 758 – 6 / 13
Graph Problems Number Problem ■ Reductions ■ Subset Sum ■ Example Formula ■ Subset Sum ■ Resulting Set ■ EOLQs Reduction to a Numeric Problem Wheeler Ruml (UNH) Class 22, CS 758 – 7 / 13
Reductions CIRCUIT-SAT Graph Problems Number Problem ■ Reductions SAT ■ Subset Sum ■ Example Formula ■ Subset Sum 3-CNF SAT ■ Resulting Set ■ EOLQs CLIQUE SUBSET-SUM VERTEX-COVER HAM-CYCLE TSP Wheeler Ruml (UNH) Class 22, CS 758 – 8 / 13
Subset Sum Given finite set of positive integers, is there a subset that sums Graph Problems to t ? Number Problem ■ Reductions ■ Subset Sum SUBSET-SUM ∈ NP: given subset, compute sum. ■ Example Formula ■ Subset Sum ■ Resulting Set SUBSET-SUM is NP-Hard: Reduction from 3-CNF SAT. Make ■ EOLQs numbers and the target sum from the formula. For n variables and k clauses, each number will have n + k digits. We ensure no carrying by using base 10 and at most a sum of 6 in each column. [ see upcoming slide for how to make numbers and target ] Polynomial time to construct and equivalent to satisfiability. Wheeler Ruml (UNH) Class 22, CS 758 – 9 / 13
Example Formula Graph Problems Number Problem C 1 : ( x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) ∧ ■ Reductions ■ Subset Sum C 2 : ( ¬ x 1 ∨ ¬ x 2 ∨ ¬ x 3 ) ∧ ■ Example Formula C 3 : ( ¬ x 1 ∨ ¬ x 2 ∨ x 3 ) ∧ ■ Subset Sum ■ Resulting Set C 4 : ( x 1 ∨ x 2 ∨ x 3 ) ■ EOLQs Wheeler Ruml (UNH) Class 22, CS 758 – 10 / 13
Subset Sum Two kinds of numbers: Graph Problems Number Problem Two numbers for each variable, representing ■ ■ Reductions positive/negative literals. (These are the ‘important’ ones!) ■ Subset Sum ■ Example Formula 1 in the variable’s column, and 1 for clauses where that ■ Subset Sum literal appears. ■ Resulting Set ■ EOLQs Clause numbers just allow slop for 1, 2 or 3 true literals per ■ clause. Target is 1 for each variable and 4 for each clause. Therefore, it requires exactly one form of each variable and at least one true literal in each clause (plus one or both ‘slop numbers’). Sum ⇒ SAT: read off assignment. Target ensures consistency and variable numbers ensure satisfiability. SAT ⇒ sum: construct sum, choosing slop variables last. Wheeler Ruml (UNH) Class 22, CS 758 – 11 / 13
Resulting Set x 1 x 2 x 3 C 1 C 2 C 3 C 4 Graph Problems v 1 = 1 0 0 1 0 0 1 Number Problem v ′ 1 = 1 0 0 0 1 1 0 ■ Reductions ■ Subset Sum v 2 = 0 1 0 0 0 0 1 ■ Example Formula v ′ 2 = 0 1 0 1 1 1 0 ■ Subset Sum ■ Resulting Set v 3 = 0 0 1 0 0 1 1 ■ EOLQs v ′ 3 = 0 0 1 1 1 0 0 s 1 = 0 0 0 1 0 0 0 s ′ 1 = 0 0 0 2 0 0 0 s 2 = 0 0 0 0 1 0 0 s ′ 2 = 0 0 0 0 2 0 0 s 3 = 0 0 0 0 0 1 0 s ′ 3 = 0 0 0 0 0 2 0 s 4 = 0 0 0 0 0 0 1 s ′ 4 = 0 0 0 0 0 0 2 t = 1 1 1 4 4 4 4 Wheeler Ruml (UNH) Class 22, CS 758 – 12 / 13
Resulting Set x 1 x 2 x 3 C 1 C 2 C 3 C 4 Graph Problems v 1 = 1 0 0 1 0 0 1 Number Problem v ′ 1 = 1 0 0 0 1 1 0 ■ Reductions ■ Subset Sum v 2 = 0 1 0 0 0 0 1 ■ Example Formula v ′ 2 = 0 1 0 1 1 1 0 ■ Subset Sum ■ Resulting Set v 3 = 0 0 1 0 0 1 1 ■ EOLQs v ′ 3 = 0 0 1 1 1 0 0 s 1 = 0 0 0 1 0 0 0 s ′ 1 = 0 0 0 2 0 0 0 s 2 = 0 0 0 0 1 0 0 s ′ 2 = 0 0 0 0 2 0 0 s 3 = 0 0 0 0 0 1 0 s ′ 3 = 0 0 0 0 0 2 0 s 4 = 0 0 0 0 0 0 1 s ′ 4 = 0 0 0 0 0 0 2 t = 1 1 1 4 4 4 4 Wheeler Ruml (UNH) Class 22, CS 758 – 12 / 13
EOLQs For example: Graph Problems Number Problem What’s still confusing? ■ ■ Reductions What question didn’t you get to ask today? ■ ■ Subset Sum ■ Example Formula What would you like to hear more about? ■ ■ Subset Sum ■ Resulting Set Please write down your most pressing question about algorithms ■ EOLQs and put it in the box on your way out. Thanks! Wheeler Ruml (UNH) Class 22, CS 758 – 13 / 13
Recommend
More recommend