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:
- Rank(v)>=2
- If rank(v)=2 then the other two vertices are not connected with one another by an edge.
- 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.