The Mathematica Journal
Volume 10, Issue 2


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

Download This Issue 

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

In and Out
Edited by Paul Abbott


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 ( 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.