Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

It looks like a bug. Please submit a bugreport at https://github.com/sagemath/sage/issues

Meanwhile, a workaround would be to store subgraphs as sorted sequences of edges in a set, which will eliminate the duplicates:

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))

This prints 48 and 8, meaning that among the 48 reported subgraphs only 8 are unique.

It looks like a bug. Please submit a bugreport at https://github.com/sagemath/sage/issues

Meanwhile, a workaround would be to store subgraphs as sorted sequences tuples of edges in a set, which will eliminate the duplicates:

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))

This prints 48 and 8, meaning that among the 48 reported subgraphs only 8 are unique.