- graph_tool.topology.all_circuits(g, unique=False)#
Return an iterator over all the cycles in a directed graph.
A directed graph to be used. (Undirected graphs are also accepted, in which case each undirected edge is assumed to be equivalent to two directed edges in both directions.)
True, parallel edges and self-loops will be ignored.
- cycle_iteratoriterator over a sequence of integers
Iterator over sequences of vertices that form a circuit.
This algorithm [R93ec26dfef43-johnson-finding-1975]_[R93ec26dfef43-hawick-enumerating-2008]_ runs in worst time \(O[(V + E)(C + 1)]\), where \(C\) is the number of circuits.
K.A. Hawick and H.A. James, “Enumerating Circuits and Loops in Graphs with Self-Arcs and Multiple-Arcs.”, In Proceedings of FCS. 2008, 14-20, http://cssg.massey.ac.nz/cstn/013/cstn-013.html
>>> g = gt.random_graph(10, lambda: (1, 1)) >>> for c in gt.all_circuits(g): ... print(c) [0 2 8 6 9 3 5 1] [4 7]