1

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.

  • Prove: There exists an efficient algorithm that returns a Hamiltonian Cycle.

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?

Gilad Gur
  • 477
  • 3
  • 10

2 Answers2

1

I'm not an expert in formal proofs, so I'll just give some observations that could be useful.

  • An invariant for your for loop is that G' always contain an Hamiltonian Cycle, so it must be proved that in G' doesn't contain edges which are not part of the cycle

  • There's a theorem that states that the number of edges of an Hamiltonian loop is equal to V + 1. So if you can prove that at the end of the loop there are exactly V + 1 edges you're done. (I don't think this is easy with the algorithm you provided, but maybe it could be with some minor modification)

  • If you can formally prove the fact that you restore the edge if and only if it is necessary for the presence of an Hamiltonian cycle than it is immediate that at the end of the loop there won't be edges not part of the cycle

Marco Zamboni
  • 224
  • 1
  • 9
1

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:

  1. ’ has a Hamilton Cycle, because that was true at the end of the last iteration
  2. There is no edge you can remove from ’ and still have a Hamilton Cycle, because you tried removing all those edges without success. Granted, sometimes ’ still had other edges at that moment of attempt, but that doesn't matter: if an edge is essential for having a Hamilton Cycle in a ’, then it still is essential after you have removed some other non-essential edges.
  3. This algorithm has not added or removed any nodes: ’ has the same nodes as
  4. This algorithm has not added any edges: the set of edges of ’ is a subset of the edges of (possibly equal to it).

From these points we can conclude that if has a Hamilton Cycle, then ’ is a Hamilton Cycle of .

trincot
  • 317,000
  • 35
  • 244
  • 286