 <p>Using depth-first search and proactive marking of nodes, you can find cycles simply by noticing any time that you run into a marked node in your search.</p> <p>This is an <code>O(V+E)</code> approach, I believe, where <code>V</code> is the number of vertices or nodes and <code>E</code> is the number of edges or connections.</p> <p>If you put the nodes in a particular branch on a stack, you can also easily determine the cycle path. Just make sure to pop a node out each time you backtrack.</p>