all_circuits can be infinite or crash
I noticed that the all_circuits function can enter an infinite loop even for very simple graphs:
import graph_tool.all as gt
g = gt.complete_graph(3, directed=True, self_loops=False)
for i, c in enumerate(gt.all_circuits(g, unique=True)):
print(i, c)
The output may look like:
...
104446 [0 2]
104447 [0 2 1]
104448 [0 2]
104449 [0 2 1]
104450 [0 2]
104451 [0 2 1]
104452 [0 2]
104453 [0 2 1]
...
Moreover, if I switch self_loops=True
, it crashes for me (and probably gives wrong result as [0]
should not be there due to unique=True
I think):
import graph_tool.all as gt
g = gt.complete_graph(3, directed=True, self_loops=True)
for i, c in enumerate(gt.all_circuits(g, unique=True)):
print(i, c)
0 [0]
1 [0 1]
2 [0 1 2]
3 [0 2]
4 [0 2 1]
Segmentation fault (core dumped)
This is with version 2.80-3 on Arch Linux.