Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/graphs/digraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3568,7 +3568,7 @@ def out_branchings(self, source, spanning=True):
-- iterator over in-branchings rooted at given vertex.
- :meth:`~sage.graphs.graph.Graph.spanning_trees`
-- returns all spanning trees.
- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
-- counts the number of spanning trees.

ALGORITHM:
Expand Down Expand Up @@ -3784,7 +3784,7 @@ def in_branchings(self, source, spanning=True):
-- iterator over out-branchings rooted at given vertex.
- :meth:`~sage.graphs.graph.Graph.spanning_trees`
-- returns all spanning trees.
- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
-- counts the number of spanning trees.

ALGORITHM:
Expand Down
16 changes: 9 additions & 7 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
:meth:`~GenericGraph.transitive_closure` | Compute the transitive closure of a graph and returns it.
:meth:`~GenericGraph.transitive_reduction` | Return a transitive reduction of a graph.
:meth:`~GenericGraph.min_spanning_tree` | Return the edges of a minimum spanning tree.
:meth:`~GenericGraph.spanning_trees_count` | Return the number of spanning trees in a graph.
:meth:`~GenericGraph.number_of_spanning_trees` | Return the number of spanning trees in a graph.
:meth:`~GenericGraph.dominator_tree` | Return a dominator tree of the graph.
:meth:`~GenericGraph.connected_subgraph_iterator` | Iterator over the induced connected subgraphs of order at most `k`

Expand Down Expand Up @@ -5359,7 +5359,7 @@ def cmp_fun(x):
for u, v in E]
raise NotImplementedError("minimum spanning tree algorithm '%s' is not implemented" % algorithm)

def spanning_trees_count(self, root_vertex=None):
def number_of_spanning_trees(self, root_vertex=None):
r"""
Return the number of spanning trees in a graph.

Expand Down Expand Up @@ -5402,14 +5402,14 @@ def spanning_trees_count(self, root_vertex=None):
EXAMPLES::

sage: G = graphs.PetersenGraph()
sage: G.spanning_trees_count() # needs sage.modules
sage: G.number_of_spanning_trees() # needs sage.modules
2000

::

sage: n = 11
sage: G = graphs.CompleteGraph(n)
sage: ST = G.spanning_trees_count() # needs sage.modules
sage: ST = G.number_of_spanning_trees() # needs sage.modules
sage: ST == n ^ (n - 2) # needs sage.modules
True

Expand All @@ -5418,11 +5418,11 @@ def spanning_trees_count(self, root_vertex=None):
sage: # needs sage.modules
sage: M = matrix(3, 3, [0, 1, 0, 0, 0, 1, 1, 1, 0])
sage: D = DiGraph(M)
sage: D.spanning_trees_count()
sage: D.number_of_spanning_trees()
1
sage: D.spanning_trees_count(0)
sage: D.number_of_spanning_trees(0)
1
sage: D.spanning_trees_count(2)
sage: D.number_of_spanning_trees(2)
2
"""
if not self.order():
Expand All @@ -5447,6 +5447,8 @@ def spanning_trees_count(self, root_vertex=None):
M[index, index] += 1
return abs(M.determinant())

spanning_trees_count = number_of_spanning_trees

def cycle_basis(self, output='vertex'):
r"""
Return a list of cycles which form a basis of the cycle space of
Expand Down
8 changes: 4 additions & 4 deletions src/sage/graphs/spanning_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def random_spanning_tree(G, output_as_graph=False, by_weight=False, weight_funct

.. SEEALSO::

:meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
:meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
and :meth:`~sage.graphs.graph.Graph.spanning_trees`

EXAMPLES::
Expand Down Expand Up @@ -1096,17 +1096,17 @@ def spanning_trees(g, labels=False):
sage: G = Graph([(1,2),(1,2),(1,3),(1,3),(2,3),(1,4)], multiedges=True)
sage: len(list(G.spanning_trees()))
8
sage: G.spanning_trees_count() # needs sage.modules
sage: G.number_of_spanning_trees() # needs sage.modules
8
sage: G = Graph([(1,2),(2,3),(3,1),(3,4),(4,5),(4,5),(4,6)], multiedges=True)
sage: len(list(G.spanning_trees()))
6
sage: G.spanning_trees_count() # needs sage.modules
sage: G.number_of_spanning_trees() # needs sage.modules
6

.. SEEALSO::

- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
-- counts the number of spanning trees

- :meth:`~sage.graphs.graph.Graph.random_spanning_tree`
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/tutte_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def tutte_polynomial(G, edge_selector=None, cache=None):
sage: G = graphs.RandomGNP(10,0.6)
sage: while not G.is_connected():
....: G = graphs.RandomGNP(10,0.6)
sage: G.tutte_polynomial()(1,1) == G.spanning_trees_count() # needs sage.modules
sage: G.tutte_polynomial()(1,1) == G.number_of_spanning_trees() # needs sage.modules
True

Given that `T(x,y)` is the Tutte polynomial of a graph `G` with
Expand Down Expand Up @@ -580,7 +580,7 @@ def tutte_polynomial(G, edge_selector=None, cache=None):
sage: g.add_edges([(0,1,1),(1,5,2),(5,3,3),(5,2,4),(2,4,5),(0,2,6),(0,3,7),(0,4,8),(0,5,9)])
sage: g.tutte_polynomial()(1,1)
52
sage: g.spanning_trees_count() # needs sage.modules
sage: g.number_of_spanning_trees() # needs sage.modules
52
"""
R = ZZ['x, y']
Expand Down
Loading