1 / 20

Odds and Ends

Odds and Ends. HP ≤ p HC (again) Turing reductions Strong NP-completeness versus Weak NP-completeness Vertex Cover to Hamiltonian Cycle. Example: HP ≤ p HC. Hamiltonian Path Input: Undirected Graph G = (V,E) Y/N Question: Does G contain a Hamiltonian Path? Hamiltonian Cycle

arden
Download Presentation

Odds and Ends

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. Odds and Ends • HP ≤p HC (again) • Turing reductions • Strong NP-completeness versus Weak NP-completeness • Vertex Cover to Hamiltonian Cycle

  2. Example: HP ≤p HC • Hamiltonian Path • Input: Undirected Graph G = (V,E) • Y/N Question: Does G contain a Hamiltonian Path? • Hamiltonian Cycle • Input: Undirected Graph G = (V,E) • Y/N Question: Does G contain a Hamiltonian Cycle?

  3. Specification of R(x) • Consider any undirected graph G = (V,E) as input x • R(x) will be a graph G’ = (V’, E’) where • V’ = V union {v} where v is not in V • E’ = E union {(v,w) | w in V} • Argument that R(x) has polynomial size • We add exactly 1 node and |V| edges.

  4. x is yes  R(x) is yes • Suppose graph G has a Hamiltonian Path • Let this path be v1, v2, …, vn • We now argue that v1, v2, …, vn, v is a Hamiltonian Cycle in G’ • First, all nodes in V’ are included exactly once above or else v1, v2, …, vn would not be a HP in G • Since G’ has all the edges that G has, (vi,vi+1) is an edge in E’ for 1 ≤ i ≤ n-1 • Finally, since E’ contains edge (v,w) for all w in V, it must be the case that E’ contains edges (vn, v) and (v,v1).

  5. R(x) is yes x is yes • Suppose graph G’ has a Hamiltonian Cycle • Let this cycle be v1, v2, …, vn, v • We now argue that v1, v2, …, vn is a Hamiltonian Path in G • First, all nodes in V are included exactly once above or else v1, v2, …, vn, v would not be a HC in G’ • Since the only extra edges in E’ compared to E are edges involving node v, it must be the case that E contains edge (vi,vi+1) for 1 ≤ i ≤ n-1

  6. Turing Reducibility • Consider the following alternate reduction. • Given graph G, output Q(n2) graphs Gv,w = (V,Ev,w) where • Ev,w = E union {(v,w)} where v,w are nodes in V • This is not a polynomial-time reduction because we are outputting Q(n2) graphs. • However, this idea can be used to show that if HC can be solved in polynomial time, then HP can be solved in polynomial time. • Run each graph Gv,w through our procedure that solves HC. • If HC says yes for any one of these graphs, return yes. • Otherwise return no. • This more general reduction is often called a Turing reduction. • We allow ourselves to use the procedure that solves HC (or P2) a polynomial number of times rather than just once.

  7. Number Problems • Problems where the inputs are numbers • Prime number problem: • Input: Integer n • Yes/No Question: Is n prime? • Partition problem • Input: Set S of n numbers {s1, …, sn} • Yes/No Question: Is there an S’ subset of S such that the sum of numbers in S’ = the sum of numbers in S – S’. • What is the input size for these problems?

  8. Knapsack Problem • 0-1 Knapsack optimization problem • Input • Capacity K • n items with weights wi and values vi • Yes/No Question • Find a set of items S such that • the sum of weights of items in S is at most K • the sum of values of items in S is maximized • We gave a dynamic programming solution for this problem • We showed that Partition ≤p Knapsack on hw 8 • Is this a contradiction?

  9. Definining subproblems • Define P(i,w) to be the problem of choosing a set of objects from the first i objects that maximizes value subject to weight constraint of w. • Impose an arbitrary ordering on the items • V(i,w) is the value of this set of items • Original problem corresponds to V(n, K)

  10. Recurrence Relation/Running Time • V(i,w) = max (V(i-1,w-wi) + vi, V(i-1, w)) • A maximal solution for P(i,w) either • uses item i (first term in max) • or does NOT use item i (second term in max) • V(0,w) = 0 (no items to choose from) • V(i,0) = 0 (no weight allowed) • What is the running time of this solution? • Number of table entries: • Time to fill each entry:

  11. Example Items wA = 2 vA = $40 wB = 3 vB = $50 wC = 1 vC = $100 wD = 5 vD = $95 wE = 3 vE = $30 Weight

  12. Weak NP-completeness • An NP-complete problem is called “weakly NP-complete” if it has in its description one or more integer parameters and the corresponding problem where these parameters are represented in unary is in P. • An NP-complete problem is strongly NP-complete if the problem is still NP-complete even if integer parameters are encoded in unary

  13. u v v u Vertex Cover to Ham Cycle Edge Component: For every edge in the Minimum Vertex Cover problem, we create a component in the Hamiltonian Cycle Problem: u v

  14. Observations…. u v u v u v v v u u v u There are only three possible ways that a cycle can include all of the vertices in this component. Key property: If a path enters v (u), it leaves on v’ (u’)

  15. Node Selection u v All components that represent edges connected to node u are strung together into a chain. If there are V vertices, then we will have V of these chains, all interwoven. Choosing a node u corresponds to traversing such a chain u v w u w u u x x u

  16. y v u w y v u w v u y w v u z x v u z v u x Vertex cover = (v,u) x z v u

  17. y v u w y v u w v u y w v u z x v u z v u x Vertex cover = (v,w,x) x z v u

  18. Tying the Chains Together If we want to know if its possible to cover the original graph using only k vertices, this would be the same as seeing if we can include all of the vertices using only k chains. How can we include exactly k chains in the Hamiltonian Cycle problem? We must add k extra vertices and connect each of them to the beginning and end of every chain. Since each vertex can only be included once, this allows k chains in the final cycle.

  19. Beginning a Transform

  20. The Final Transform for k=1

More Related