0

I'm trying to do a lot of programming exercises to understand concepts and get hands-on experience practice by tackling them.

I've stumbled upon an exercise that gives a set of conditions as to how the graph is like and requires you to find out whether or not a Hamiltonian cycle is possible or not, and if there is, print out of one the possibilities.

Since the exercise is in my native language, I've translated it as best as I could and it goes as follows:

Let there be a graphic G=(V,E), having the number of vertices V and the number of edges E. We will notate N(v) as the set of vertices connected to v. The number of adjacent vertices of a vertex is called rank and we notate it with rank(v).

We say that the graphic G is weird if it is conex and for every vertex of the graph the next conditions are met:

  1. Rank(v)>=2
  2. If rank(v)=2 then the other two vertices are not connected with one another by an edge.
  3. If rank(v)>2 then the set of adjacent vertices of v there exists a vertex u ( u ∈ N(v) ), so the following properties are true: I. Rank(u)=2 AND II. Every other two distinct vertices of the adjacent vertices of v, (w1,w2 ∈ N(v)-{u} ) are connected to one another, so (w1,w2) ∈ E.

Every graph required to solve is to be considered a "weird" graph.

How does one tackle this problem? You need to drastically minimize computation time with the help of the conditions, but I can't think of a trick/pattern to search the Hamiltonian cycle with them as of yet. Thanks in advance.

Alias
  • 1
  • 1
  • You should make the question a programming one, by showing some effort in testing with some program and results expected vs obtained. – Efren Mar 06 '18 at 23:38
  • I would gladly do so, but I don't have the slightest clue on how to interpret the third condition into code to find a Hamiltonian cycle. I would implement some type of backtracking, but I expect that to fail due to the insane computation it requires when the cycle is not possible in the graph. Tried drawing some graphs out and figuring out a pattern, but to no avail. – Alias Mar 08 '18 at 15:20

0 Answers0