Let G(V,E) be an undirected graph. A Hamiltonian cycle is a cycle that visits each vertex v of G exactly once (except the first vertex, which is also the last vertex in the cycle).
Assume: There Exists an efficient algorithm that determines if a graph has a Hamiltonian cycle (returns True\False). Let's call this alg' D for Determine.
My answer attempt
Assume D(G) = true
Let G'=G (Define G' a copy of G).
For each edge e in E:
G' = G' \ {e} // Remove e from G.
d_boolean = D(G') // Run D alg' on the new Graph.
if d_boolean = false
then G' = G' U {e} // restore e to graph (because e must be in the Hamiltonian Cycle)
// else d_boolean=true we do nothing because e is not an edge on the Hamiltonian Cycle
Return G'
My Question
As you can see, I have an idea of an algorithm to show that one exists. I feel it's the right direction... But how do I prove that this algorithm actually returns the Hamiltonian Cycle?
There is just one element missing in your pseudo code: it is not guaranteed that 𝐺 has a Hamilton Cycle.
So you would need to have a first check, before doing anything else, that ensures that it does have a Hamilton Cycle.
If not D(G):
Return No_Hamilton_Cycle!
Secondly, the algorithm returns a Hamilton Cycle (not the): there can be many alternative Hamilton Cycles in 𝐺, but the order in which you try removing edges, determines which one of those competing Hamilton Cycles you will finally get.
With the above addition, you can be sure that at the start and end of each iteration, 𝐺’ has a Hamilton Cycle: either an iteration will remove an edge and confirm that 𝐺’ still has a Hamilton Cycle, or that removal is undone, so that the state of 𝐺’ is the same at the end as as at the start of that iteration.
When the loop has finished you know that:
From these points we can conclude that if 𝐺 has a Hamilton Cycle, then 𝐺’ is a Hamilton Cycle of 𝐺.