How can I find the number of Hamiltonian cycles in a complete undirected graph?
-
Can someone explain how to find the number of Hamiltonian cycles in a complete undirected graph? http://en.wikipedia.org/wiki/Hamiltonian_path#Properties that the formula is (n-1)!/2, but when I calculated using this formula, K3 has only one cycle and K4 has 5. Was my calculation incorrect?
-
Answer:
Since the graph is complete, any permutation starting with a fixed vertex gives an (almost) unique cycle (the last vertex in the permutation will have an edge back to the first, fixed vertex. Except for one thing: if you visit the vertices in the cycle in reverse order, then that's really the same cycle (because of this, the number is half of what permutations of (n-1) vertices would give you). e.g. for vertices 1,2,3, fix "1" and you have: 123 132 but 123 reversed (321) is a rotation of (132), because 32 is 23 reversed. There are (n-1)! permutations of the non-fixed vertices, and half of those are the reverse of another, so there are (n-1)!/2 distinct Hamiltonian cycles in the complete graph of n vertices.
avd at Stack Overflow Visit the source
Other answers
In answer to your Google Code Jam comment, see http://stackoverflow.com/questions/6038367/
xan
Related Q & A:
- How can I find the minimum number of open rectangles in a grid?Best solution by Stack Overflow
- How can I find out how many GBs I use a month on Internet?Best solution by Yahoo! Answers
- How can I find the address with just a phone number?Best solution by Yahoo! Answers
- How can I find address from vehicle number?Best solution by Yahoo! Answers
- How do I find the number to a lost U.S. passport?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.