The Mathematica Journal
Volume 10, Issue 2

Search

In This Issue
Articles
In and Out
Trott's Corner
Beyond Sudoku
New Products
New Publications
Calendar
News Bulletins
New Resources
Classifieds

Download This Issue 

About the Journal
Editorial Policy
Staff and Contributors
Submissions
Subscriptions
Advertising
Back Issues
Contact Information

In and Out
Edited by Paul Abbott

HamiltonianCycle

Q: I am interested in counting the number of paths from a node in a network back to that node, counting loops (cycles) only once. Is there any readily available code that does this?

A: Steve Luttrell (steve_usenet@luttrell.org.uk) answers: Use HamiltonianCycle in the DiscreteMath`Combinatorica` package. Here is an example of how this solves your problem.

Load the DiscreteMath`Combinatorica` package.

Here is a random, labeled graph on 10 vertices with an edge probability of .

Using Highlight, display a HamiltonianCycle of the graph g.

The total number of Hamiltonian cycles is equal to the number of loops that start from and eventually return to any starting node, having visited every other node exactly once.



     
About Mathematica | Download Mathematica Player 
© Wolfram Media, Inc. All rights reserved.