
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Review: P and NP
Review: NP-Complete
Review: NP-Complete
■ P is “no harder than” Q
■ Transform instances of P to instances of Q in polynomial time s.t. Q: “yes” iff P: “yes”
■ Every problem P∈ NP ≤p Q
■ Q is NP-Hard and Q ∈ NP Docsity.com
Review: Directed ⇒ Undirected Ham. Cycle
■ Every vertex v in V transforms into 3 vertices v^1 , v^2 , v^3 in V’ with edges ( v^1 , v^2 ) and ( v^2 , v^3 ) in E’ ■ Every directed edge ( v , w ) in E transforms into the undirected edge ( v^3 , w^1 ) in E’ (draw it)
Review:
Directed ⇒ Undirected Ham. Cycle
■ If G has directed hamiltonian cycle, G’ will have undirected cycle (straightforward) ■ If G’ has an undirected hamiltonian cycle, G will have a directed hamiltonian cycle ○ The three vertices that correspond to a vertex v in G must be traversed in order v^1 , v^2 , v^3 or v^3 , v^2 , v^1 , since v^2 cannot be reached from any other vertex in G’ ○ Since 1’s are connected to 3’s, the order is the same for all triples. Assume w.l.o.g. order is v^1 , v^2 , v^3. ○ Then G has a corresponding directed hamiltonian cycle
Review: Hamiltonian Cycle ⇒ TSP
■ G’ is a complete graph ■ Edges in E’ also in E have weight 0 ■ All other edges in E’ have weight 1 ■ TSP: is there a TSP on G’ with weight 0? ○ If G has a hamiltonian cycle, G’ has a cycle w/ weight 0 ○ If G’ has cycle w/ weight 0, every edge of that cycle has weight 0 and is thus in G. Thus G has a ham. cycle
The SAT Problem
■ Given a Boolean expression on n variables, can we assign values such that the expression is TRUE? ■ Ex: (( x 1 → x 2 ) ∨ ¬((¬ x 1 ↔ x 3 ) ∨ x 4 )) ∧¬ x 2 ■ Cook’s Theorem: The satisfiability problem is NP-Complete ○ Note: Argue from first principles, not reduction ○ Proof: not here
The 3-CNF Problem
■ Proof: Nope
■ Thus by proving 3-CNF NP-Complete we can prove many seemingly unrelated problems NP-Complete
3-CNF → Clique
3-CNF → Clique
■ Let B = C 1 ∧ C 2 ∧ … ∧ C k be a 3-CNF formula with k clauses, each of which has 3 distinct literals ■ For each clause put a triple of vertices in the graph, one for each literal ■ Put an edge between two vertices if they are in different triples and their literals are consistent , meaning not each other’s negation ■ Run an example: B = (x ∨ ¬y ∨ ¬z) ∧ (¬x ∨ y ∨ z ) ∧ (x ∨ y ∨ z )
3-CNF → Clique
■ If B has a satisfying assignment, then each clause has at least one literal (vertex) that evaluates to 1 ■ Picking one such “true” literal from each clause gives a set V’ of k vertices. V’ is a clique ( Why? ) ■ If G has a clique V’ of size k, it must contain one vertex in each triple (clause) ( Why? ) ■ We can assign 1 to each literal corresponding with a vertex in V’, without fear of contradiction
Clique → Vertex Cover
■ The complement GC of a graph G contains exactly those edges not in G ■ Compute G (^) C in polynomial time ■ G has a clique of size k iff G (^) C has a vertex cover of size |V| - k
Clique → Vertex Cover
■ Let V’ be the k -clique ■ Then V - V’ is a vertex cover in G (^) C ○ Let ( u,v ) be any edge in G (^) C ○ Then u and v cannot both be in V’ ( Why? ) ○ Thus at least one of u or v is in V-V’ ( why? ), so edge ( u , v ) is covered by V-V’ ○ Since true for any edge in G (^) C, V-V’ is a vertex cover