Skip to content

Commit dae71a1

Browse files
committed
set sort edges to False by default
1 parent 0fd5967 commit dae71a1

File tree

3 files changed

+13
-36
lines changed

3 files changed

+13
-36
lines changed

src/sage/graphs/digraph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3614,7 +3614,8 @@ def flow_polytope(self, edges=None, ends=None, backend=None):
36143614
36153615
Using a different order for the edges of the graph::
36163616
3617-
sage: fl = G.flow_polytope(edges=G.edges(key=lambda x: x[0] - x[1])); fl # needs sage.geometry.polyhedron
3617+
sage: ordered_edges = G.edges(sort=True, key=lambda x: x[0] - x[1])
3618+
sage: fl = G.flow_polytope(edges=ordered_edges); fl # needs sage.geometry.polyhedron
36183619
A 1-dimensional polyhedron in QQ^4 defined as the convex hull of 2 vertices
36193620
sage: fl.vertices() # needs sage.geometry.polyhedron
36203621
(A vertex at (0, 1, 1, 0), A vertex at (1, 0, 0, 1))

src/sage/graphs/generic_graph.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12371,7 +12371,7 @@ def has_edge(self, u, v=None, label=None):
1237112371
label = None
1237212372
return self._backend.has_edge(u, v, label)
1237312373

12374-
def edges(self, vertices=None, labels=True, sort=None, key=None,
12374+
def edges(self, vertices=None, labels=True, sort=False, key=None,
1237512375
ignore_direction=False, sort_vertices=True):
1237612376
r"""
1237712377
Return a :class:`~EdgesView` of edges.
@@ -12395,13 +12395,10 @@ def edges(self, vertices=None, labels=True, sort=None, key=None,
1239512395
- ``labels`` -- boolean (default: ``True``); if ``False``, each edge is
1239612396
simply a pair ``(u, v)`` of vertices
1239712397

12398-
- ``sort`` -- boolean (default: ``None``); if ``True``, edges are sorted
12399-
according to the default ordering
12400-
12401-
As of :trac:`22349`, this argument must be explicitly
12402-
specified (unless a ``key`` is given); otherwise a warning
12403-
is printed and ``sort=True`` is used. The default will
12404-
eventually be changed to ``False``.
12398+
- ``sort`` -- boolean (default: ``False``); whether to sort edges
12399+
according the ordering specified with parameter ``key``. If ``False``
12400+
(default), edges are not sorted. This is the fastest and less memory
12401+
consuming method for iterating over edges.
1240512402

1240612403
- ``key`` -- a function (default: ``None``); a function that takes an
1240712404
edge (a pair or a triple, according to the ``labels`` keyword) as its
@@ -12497,7 +12494,7 @@ def edges(self, vertices=None, labels=True, sort=None, key=None,
1249712494
....: G.set_edge_label(e[0], e[1], chr(ord('A') + e[0] + 5 * e[1]))
1249812495
sage: G.edges(sort=True)
1249912496
[(0, 1, 'F'), (0, 4, 'U'), (1, 2, 'L'), (2, 3, 'R'), (3, 4, 'X')]
12500-
sage: G.edges(key=lambda x: x[2])
12497+
sage: G.edges(sort=True, key=lambda x: x[2])
1250112498
[(0, 1, 'F'), (1, 2, 'L'), (2, 3, 'R'), (0, 4, 'U'), (3, 4, 'X')]
1250212499

1250312500
We can restrict considered edges to those incident to a given set::
@@ -12548,20 +12545,7 @@ def edges(self, vertices=None, labels=True, sort=None, key=None,
1254812545
sage: G.edge_label(0, 1)[0] += 1
1254912546
sage: G.edges(sort=True)
1255012547
[(0, 1, [8]), (0, 2, [7])]
12551-
12552-
Deprecation warning for ``sort=None`` (:trac:`27408`)::
12553-
12554-
sage: G = graphs.HouseGraph()
12555-
sage: G.edges(sort=None)
12556-
doctest:...: DeprecationWarning: parameter 'sort' will be set to False by default in the future
12557-
See https://github.com/sagemath/sage/issues/27408 for details.
12558-
[(0, 1, None), (0, 2, None), (1, 3, None), (2, 3, None), (2, 4, None), (3, 4, None)]
1255912548
"""
12560-
if sort is None:
12561-
if key is None:
12562-
deprecation(27408, "parameter 'sort' will be set to False by default in the future")
12563-
sort = True
12564-
1256512549
if vertices is not None and vertices in self:
1256612550
vertices = [vertices]
1256712551

src/sage/graphs/views.pyx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ cdef class EdgesView:
6464
- ``ignore_direction`` -- boolean (default: ``False``); only applies to
6565
directed graphs. If ``True``, searches across edges in either direction.
6666
67-
- ``sort`` -- boolean (default: ``None``); whether to sort edges
68-
69-
- if ``None``, sort edges according to the default ordering and give a
70-
deprecation warning as sorting will be set to ``False`` by default in
71-
the future
72-
73-
- if ``True``, edges are sorted according the ordering specified with
74-
parameter ``key``
75-
76-
- if ``False``, edges are not sorted. This is the fastest and less memory
77-
consuming method for iterating over edges. This will become the default
78-
behavior in the future.
67+
- ``sort`` -- boolean (default: ``False``); whether to sort edges according
68+
the ordering specified with parameter ``key``. If ``False`` (default),
69+
edges are not sorted. This is the fastest and less memory consuming method
70+
for iterating over edges.
7971
8072
- ``key`` -- a function (default: ``None``); a function that takes an edge
8173
(a pair or a triple, according to the ``labels`` keyword) as its one
@@ -350,7 +342,7 @@ cdef class EdgesView:
350342

351343
def __init__(self, G, vertices=None, vertices2=None, labels=True,
352344
ignore_direction=False,
353-
sort=None, key=None, sort_vertices=True):
345+
sort=False, key=None, sort_vertices=True):
354346
"""
355347
Construction of this :class:`EdgesView`.
356348

0 commit comments

Comments
 (0)