Consider the following programsage: G = graphs.OddGraph(4)
sage: G.spanning_trees_count()
336140000000000000It takes approximately 8 minutes to compute the number of spanning trees using this method. However, the number of spanning trees can be computed directly from the charpoly of the respective Kirchhoff matrix
sage: (G.kirchhoff_matrix()).charpoly().coeffs()[1]/35
336140000000000000which takes an instant (less than a second) to compute.
Looking at the way spanning_trees_count is implemented within generic_graph.py, one can see:
M=self.kirchhoff_matrix()
M.subdivide(1,1)
M2 = M.subdivision(1,1)
return abs(M2.determinant()) # <-The abs() here is redundant someone should remove itTo speed the computation one can pass the parameter algorithm='padic' to the determinant() method and get the result of spanning_trees_count() instantly.