50 likes | 185 Views
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).
E N D
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) • 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
Turing Reducibility • 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.