1 / 5

# Example: HP p HC - PowerPoint PPT Presentation

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?. Specification of R(x).

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Example: HP p HC' - chrissy

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
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?

• 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.

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).

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

• Steve made a suggestion for an 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.