[feature] number of cycles
Hello Tiago, I was working on a research project on a bipartite graph (at ISI with prof.Paolotti) and I noticed that there is no function to count the number of closed cycle in graph-tool for an undirected graph. I ended up using the code below to retrieve the number of 4-cycles, you might want to make it available to other researchers as well. Thx for your great work!
num_v = g.num_vertices()
cycles=0
for k in range(num_v):
for path in gt.topology.all_paths(g,k,k,cutoff=4):
if len(path) == 5:
cycles += 1
cycles /= 8