Skip to content

Commit 6dc6820

Browse files
author
Release Manager
committed
gh-41155: replace spanning_trees_count with number_of_spanning_trees for consistency See also #40935. We do not deprecate `spanning_trees_count`, but we do not advertise it anymore. URL: #41155 Reported by: Martin Rubey Reviewer(s): David Coudert
2 parents 1327240 + e6fb3c4 commit 6dc6820

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/sage/graphs/digraph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,7 +3568,7 @@ def out_branchings(self, source, spanning=True):
35683568
-- iterator over in-branchings rooted at given vertex.
35693569
- :meth:`~sage.graphs.graph.Graph.spanning_trees`
35703570
-- returns all spanning trees.
3571-
- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
3571+
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
35723572
-- counts the number of spanning trees.
35733573
35743574
ALGORITHM:
@@ -3784,7 +3784,7 @@ def in_branchings(self, source, spanning=True):
37843784
-- iterator over out-branchings rooted at given vertex.
37853785
- :meth:`~sage.graphs.graph.Graph.spanning_trees`
37863786
-- returns all spanning trees.
3787-
- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
3787+
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
37883788
-- counts the number of spanning trees.
37893789
37903790
ALGORITHM:

src/sage/graphs/generic_graph.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
:meth:`~GenericGraph.transitive_closure` | Compute the transitive closure of a graph and returns it.
267267
:meth:`~GenericGraph.transitive_reduction` | Return a transitive reduction of a graph.
268268
:meth:`~GenericGraph.min_spanning_tree` | Return the edges of a minimum spanning tree.
269-
:meth:`~GenericGraph.spanning_trees_count` | Return the number of spanning trees in a graph.
269+
:meth:`~GenericGraph.number_of_spanning_trees` | Return the number of spanning trees in a graph.
270270
:meth:`~GenericGraph.dominator_tree` | Return a dominator tree of the graph.
271271
:meth:`~GenericGraph.connected_subgraph_iterator` | Iterator over the induced connected subgraphs of order at most `k`
272272

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

5362-
def spanning_trees_count(self, root_vertex=None):
5362+
def number_of_spanning_trees(self, root_vertex=None):
53635363
r"""
53645364
Return the number of spanning trees in a graph.
53655365

@@ -5402,14 +5402,14 @@ def spanning_trees_count(self, root_vertex=None):
54025402
EXAMPLES::
54035403

54045404
sage: G = graphs.PetersenGraph()
5405-
sage: G.spanning_trees_count() # needs sage.modules
5405+
sage: G.number_of_spanning_trees() # needs sage.modules
54065406
2000
54075407

54085408
::
54095409

54105410
sage: n = 11
54115411
sage: G = graphs.CompleteGraph(n)
5412-
sage: ST = G.spanning_trees_count() # needs sage.modules
5412+
sage: ST = G.number_of_spanning_trees() # needs sage.modules
54135413
sage: ST == n ^ (n - 2) # needs sage.modules
54145414
True
54155415

@@ -5418,11 +5418,11 @@ def spanning_trees_count(self, root_vertex=None):
54185418
sage: # needs sage.modules
54195419
sage: M = matrix(3, 3, [0, 1, 0, 0, 0, 1, 1, 1, 0])
54205420
sage: D = DiGraph(M)
5421-
sage: D.spanning_trees_count()
5421+
sage: D.number_of_spanning_trees()
54225422
1
5423-
sage: D.spanning_trees_count(0)
5423+
sage: D.number_of_spanning_trees(0)
54245424
1
5425-
sage: D.spanning_trees_count(2)
5425+
sage: D.number_of_spanning_trees(2)
54265426
2
54275427
"""
54285428
if not self.order():
@@ -5447,6 +5447,8 @@ def spanning_trees_count(self, root_vertex=None):
54475447
M[index, index] += 1
54485448
return abs(M.determinant())
54495449

5450+
spanning_trees_count = number_of_spanning_trees
5451+
54505452
def cycle_basis(self, output='vertex'):
54515453
r"""
54525454
Return a list of cycles which form a basis of the cycle space of

src/sage/graphs/spanning_tree.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ def random_spanning_tree(G, output_as_graph=False, by_weight=False, weight_funct
947947
948948
.. SEEALSO::
949949
950-
:meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
950+
:meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
951951
and :meth:`~sage.graphs.graph.Graph.spanning_trees`
952952
953953
EXAMPLES::
@@ -1096,17 +1096,17 @@ def spanning_trees(g, labels=False):
10961096
sage: G = Graph([(1,2),(1,2),(1,3),(1,3),(2,3),(1,4)], multiedges=True)
10971097
sage: len(list(G.spanning_trees()))
10981098
8
1099-
sage: G.spanning_trees_count() # needs sage.modules
1099+
sage: G.number_of_spanning_trees() # needs sage.modules
11001100
8
11011101
sage: G = Graph([(1,2),(2,3),(3,1),(3,4),(4,5),(4,5),(4,6)], multiedges=True)
11021102
sage: len(list(G.spanning_trees()))
11031103
6
1104-
sage: G.spanning_trees_count() # needs sage.modules
1104+
sage: G.number_of_spanning_trees() # needs sage.modules
11051105
6
11061106
11071107
.. SEEALSO::
11081108
1109-
- :meth:`~sage.graphs.generic_graph.GenericGraph.spanning_trees_count`
1109+
- :meth:`~sage.graphs.generic_graph.GenericGraph.number_of_spanning_trees`
11101110
-- counts the number of spanning trees
11111111
11121112
- :meth:`~sage.graphs.graph.Graph.random_spanning_tree`

src/sage/graphs/tutte_polynomial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def tutte_polynomial(G, edge_selector=None, cache=None):
550550
sage: G = graphs.RandomGNP(10,0.6)
551551
sage: while not G.is_connected():
552552
....: G = graphs.RandomGNP(10,0.6)
553-
sage: G.tutte_polynomial()(1,1) == G.spanning_trees_count() # needs sage.modules
553+
sage: G.tutte_polynomial()(1,1) == G.number_of_spanning_trees() # needs sage.modules
554554
True
555555
556556
Given that `T(x,y)` is the Tutte polynomial of a graph `G` with
@@ -580,7 +580,7 @@ def tutte_polynomial(G, edge_selector=None, cache=None):
580580
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)])
581581
sage: g.tutte_polynomial()(1,1)
582582
52
583-
sage: g.spanning_trees_count() # needs sage.modules
583+
sage: g.number_of_spanning_trees() # needs sage.modules
584584
52
585585
"""
586586
R = ZZ['x, y']

0 commit comments

Comments
 (0)