Checking if a Hamilton Cycle exists in a dense graph
Asked Answered
B

2

2

A few definitions first:

Definition 1

A graph G = (V, E) is called ``dense'' if for each pair of non-adjacent vertices u and v, d(u) + d(v)>=n where n = |V| and d(*) denotes the degree of the vertex *

Definition 2

A ``Hamiltonian cycle'' on G is a sequence of vertices ( vi1, vi2,....vin, vi1 ) such that vil != vih for all l!=h and { vil, vil} is an edge of G.

The problem is: write a program that, given a dense undirected graph G = (V; E) as input, determines whether G admits a Hamiltonian cycle on G and outputs that cycle, if there is one, or outputs ``N'' if there is none.

my solution is to find all the possible paths starting from a source and to check if a path exists that gets back to this source. Unfortunately, this solution is not efficient.

any suggestions? Thank you.

Brasil answered 25/6, 2012 at 8:50 Comment(4)
This uses dynamic programming to do the job.Delisadelisle
Though the above post mentions it, I'll mention it as well to save some searching time - an algorithm exists, but it's not polynomial time. The decision version of Hamiltonian Cycle is NP-Hard. You're not going to find an "efficient" solution - well, if you do, then the computer science community would love to hear it. :)Magnanimous
According to Ore's theorem (en.wikipedia.org/wiki/Ore%27s_theorem), graphs satisfying Definition 1 always have a Hamiltonian cycle.Tufts
Wow...this is true @Tamás.....Thank you!Brasil
C
7

According to Ore's theorem, graphs satisfying Definition 1 always have a Hamiltonian cycle, and Palmer's algorithm will give you one in O(n2).

Cleek answered 25/6, 2012 at 9:0 Comment(0)
W
-2

The problem is NP-hard. So I would not expect any solution to be much faster than brute-force.

Warehouseman answered 25/6, 2012 at 8:54 Comment(4)
Is it NP-hard even on dense graphs?Shaker
@avakar: No, it isn't; see my answer.Tufts
it's a trick....since the given graph is dense, it has Hamilton path! but Tamas, you should also output that path which will not improve the solution!Brasil
oh sorry, when I answered the question, the definition of density was not included in the question, so I just gave an answer for the common case.Warehouseman

© 2022 - 2024 — McMap. All rights reserved.