Find all cycles in a graph implementation
<p>I have found a simple algorithm to find all cycles in a graph <a href="https://stackoverflow.com/a/549312">here</a>. I need to print out the cycles too, is it possible with this algorithm. Please find the code below. </p>

<p>I'm getting the number of cycles correctly!</p>

<p>node1, node2 are integers. visited is a dictionary</p>

<pre><code>def dfs(self,node1, node2):
    if self.visited[node2]:
        if(node1 == node2):
            self.count += 1
            print node2
        return

    self.visited[node2] = True

    for x in self.adj_lst[node2-1]:
        self.dfs(node1, x)

    self.visited[node2] = False

def allCycles(self):
    self.count = 0
    for x in self.VList:
        self.dfs(x.num, x.num)
        self.visited[x.num] = True

    print "Number of cycles: "+str(self.count)
</code></pre>