How to determine whether a graph has l cycles of length k exactly?
Given integersl≥0, k≥3, and a graph, I want to know if it contains l k-cycles exactly. I could enumerate all cycles of length k using the link below and count them, but this might not be very efficient. - subgraph_search_iterator-gives-duplicate-subgraphs
G=graphs.OctahedralGraph()
H = graphs.CycleGraph(3)
print( sum(1 for _ in G.subgraph_search_iterator(H, induced=False,return_graphs=False) ) )
L = { tuple(g.edges(labels=False,sort_vertices=True,sort=True)) for g in G.subgraph_search_iterator(H, induced=False) }
print(len(L))
In an import case for me, determinie if a graph has a unique k-cycle (when k=1), I don't need to list all cycles and then check; instead, obtaining two cycles would suffice, and the algorithm stops.
Similarly, such questions can be asked about subgraphs