Algorithms icon indicating copy to clipboard operation
Algorithms copied to clipboard

Hamiltonian cycle in cpp, java, python.

Open vimarsh11 opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe. A Hamiltonian cycle (or Hamiltonian circuit) is a Hamiltonian path that is a cycle. Determining whether such paths and cycles exist in graphs is the Hamiltonian path problem, which is NP-complete.

Hamiltonian paths and cycles are named after William Rowan Hamilton who invented the icosian game, now also known as Hamilton's puzzle, which involves finding a Hamiltonian cycle in the edge graph of the dodecahedron. Hamilton solved this problem using the icosian calculus, an algebraic structure based on roots of unity with many similarities to the quaternions (also invented by Hamilton). This solution does not generalize to arbitrary graphs.

Describe the solution you'd like CPP/Java/Python: Represent the graph using an adjacency matrix or an adjacency list. Start with an empty path and mark all vertices as unvisited. Choose a starting vertex and mark it as visited. Recursively explore unvisited adjacent vertices from the current vertex. If all vertices are visited and the last vertex has an edge to the starting vertex, a Hamiltonian cycle is found. Otherwise, backtrack by marking the current vertex as unvisited and continue exploring other paths. Repeat the above steps for all possible starting vertices until a Hamiltonian cycle is found or all paths are explored.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here. Screenshot 2023-06-06 011301

vimarsh11 avatar Jun 05 '23 19:06 vimarsh11

Assigned! @vimarsh11 : C, C++, Python

Kumar-laxmi avatar Jun 07 '23 15:06 Kumar-laxmi

@vimarsh11 What is your status on this issue?

Kumar-laxmi avatar Jun 11 '23 02:06 Kumar-laxmi

@vimarsh11 What is your status on this issue? @Kumar-laxmi Yes, I'm working on it. I will do it by today.

vimarsh11 avatar Jun 11 '23 08:06 vimarsh11

I would like to work on this issue, kindly assign this to me.

Tanyamodi avatar Jul 14 '23 05:07 Tanyamodi

Stale issue message

github-actions[bot] avatar Jun 29 '24 16:06 github-actions[bot]