Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac 22349: edge sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpalmieri committed Jul 18, 2022
1 parent 1ec4bdf commit a9ecbc5
Show file tree
Hide file tree
Showing 126 changed files with 695 additions and 684 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/prep/Quickstarts/Graphs-and-Discrete.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Edges can be labeled.
::

sage: L=graphs.CycleGraph(5)
sage: for edge in L.edges():
sage: for edge in L.edges(sort=True):
....: u = edge[0]
....: v = edge[1]
....: L.set_edge_label(u, v, u*v)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ up to a relabeling of the arrows::
sage: G = K.digraph()
sage: Gdual = Kdual.digraph()
sage: f = { 1:1, 0:2, 2:0 }
sage: for u,v,label in Gdual.edges():
sage: for u,v,label in Gdual.edges(sort=False):
....: Gdual.set_edge_label(u,v,f[label])
sage: G.is_isomorphic(Gdual, edge_labels = True)
True
Expand Down
4 changes: 2 additions & 2 deletions src/doc/en/thematic_tutorials/linear_programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ Let us write the Sage code of this MILP::
::

sage: p.set_objective(p.sum(matching[e] for e in g.edges(labels=False)))
sage: p.set_objective(p.sum(matching[e] for e in g.edges(sort=False, labels=False)))

.. link
Expand Down Expand Up @@ -417,7 +417,7 @@ graph, in which all the edges have a capacity of 1::
::

sage: for e in g.edges(labels=False):
sage: for e in g.edges(sort=False, labels=False):
....: p.add_constraint(f[e] <= 1)

.. link
Expand Down
8 changes: 4 additions & 4 deletions src/sage/categories/coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def coxeter_diagram(self):
sage: W = CoxeterGroup(['H',3], implementation="reflection")
sage: G = W.coxeter_diagram(); G
Graph on 3 vertices
sage: G.edges()
sage: G.edges(sort=True)
[(1, 2, 3), (2, 3, 5)]
sage: CoxeterGroup(G) is W
True
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def bruhat_graph(self, x=None, y=None, edge_labels=False):
Check that the graph has the correct number of edges
(see :trac:`17744`)::
sage: len(G.edges())
sage: len(G.edges(sort=False))
16
"""
if x is None or x == 1:
Expand Down Expand Up @@ -1682,9 +1682,9 @@ def reduced_word_graph(self):
16
sage: G.num_edges()
18
sage: len([e for e in G.edges() if e[2] == 2])
sage: len([e for e in G.edges(sort=False) if e[2] == 2])
10
sage: len([e for e in G.edges() if e[2] == 3])
sage: len([e for e in G.edges(sort=False) if e[2] == 3])
8
TESTS::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ def digraph(self, subset=None, index_set=None):
sage: C = crystals.KirillovReshetikhin(['D',4,1], 2, 1)
sage: G = C.digraph(index_set=[1,3])
sage: len(G.edges())
sage: len(G.edges(sort=False))
20
sage: view(G) # optional - dot2tex graphviz, not tested (opens external window)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def e(self, i):
[[1, 1, 0], [2, 1, 1], [3, 1, 2], [5, 1, 3], [4, 2, 0], [5, 2, 4]]
"""
assert i in self.index_set()
for edge in self.parent().G.edges():
for edge in self.parent().G.edges(sort=False):
if edge[1] == int(str(self)) and edge[2] == i:
return self.parent()(edge[0])
return None
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class DihedralGroup(UniqueRepresentation, Parent):
sage: TestSuite(G).run()
sage: c = FiniteCoxeterGroups().example(3).cayley_graph()
sage: sorted(c.edges())
sage: c.edges(sort=True)
[((), (1,), 1),
((), (2,), 2),
((1,), (), 1),
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def weak_poset(self, side="right", facade=False):
sage: W = WeylGroup(["A",2])
sage: P = W.weak_poset(side = "twosided")
sage: P.show()
sage: len(P.hasse_diagram().edges())
sage: len(P.hasse_diagram().edges(sort=False))
8
This is the transitive closure of the union of left and
Expand Down Expand Up @@ -869,7 +869,7 @@ def coxeter_knuth_graph(self):
(2, 1, 2, 3, 2),
(2, 1, 3, 2, 3),
(2, 3, 1, 2, 3)]
sage: D.edges()
sage: D.edges(sort=True)
[((1, 2, 1, 3, 2), (1, 2, 3, 1, 2), None),
((1, 2, 1, 3, 2), (2, 1, 2, 3, 2), None),
((2, 1, 2, 3, 2), (2, 1, 3, 2, 3), None),
Expand All @@ -879,7 +879,7 @@ def coxeter_knuth_graph(self):
sage: D = w.coxeter_knuth_graph()
sage: D.vertices(sort=True)
[(1, 3), (3, 1)]
sage: D.edges()
sage: D.edges(sort=False)
[]
TESTS::
Expand Down
18 changes: 9 additions & 9 deletions src/sage/categories/regular_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ def demazure_subcrystal(self, element, reduced_word, only_support=True):
sage: K = crystals.KirillovReshetikhin(['A',1,1], 1, 2)
sage: mg = K.module_generator()
sage: S = K.demazure_subcrystal(mg, [1])
sage: S.digraph().edges()
sage: S.digraph().edges(sort=True)
[([[1, 1]], [[1, 2]], 1), ([[1, 2]], [[2, 2]], 1)]
sage: S = K.demazure_subcrystal(mg, [1], only_support=False)
sage: S.digraph().edges()
sage: S.digraph().edges(sort=True)
[([[1, 1]], [[1, 2]], 1),
([[1, 2]], [[1, 1]], 0),
([[1, 2]], [[2, 2]], 1),
Expand Down Expand Up @@ -382,12 +382,12 @@ def dual_equivalence_graph(self, X=None, index_set=None, directed=True):
sage: T = crystals.Tableaux(['A',3], shape=[2,2])
sage: G = T.dual_equivalence_graph()
sage: sorted(G.edges())
sage: G.edges(sort=True)
[([[1, 3], [2, 4]], [[1, 2], [3, 4]], 2),
([[1, 2], [3, 4]], [[1, 3], [2, 4]], 3)]
sage: T = crystals.Tableaux(['A',4], shape=[3,2])
sage: G = T.dual_equivalence_graph()
sage: sorted(G.edges())
sage: G.edges(sort=True)
[([[1, 3, 5], [2, 4]], [[1, 3, 4], [2, 5]], 4),
([[1, 3, 5], [2, 4]], [[1, 2, 5], [3, 4]], 2),
([[1, 3, 4], [2, 5]], [[1, 2, 4], [3, 5]], 2),
Expand All @@ -399,18 +399,18 @@ def dual_equivalence_graph(self, X=None, index_set=None, directed=True):
sage: G = T.dual_equivalence_graph(index_set=[1,2,3])
sage: G.vertices(sort=True)
[[[1, 3, 4], [2]], [[1, 2, 4], [3]], [[1, 2, 3], [4]]]
sage: G.edges()
sage: G.edges(sort=True)
[([[1, 3, 4], [2]], [[1, 2, 4], [3]], 2),
([[1, 2, 4], [3]], [[1, 2, 3], [4]], 3)]
TESTS::
sage: T = crystals.Tableaux(['A',4], shape=[3,1])
sage: G = T.dual_equivalence_graph(index_set=[2,3])
sage: sorted(G.edges())
sage: G.edges(sort=True)
[([[1, 2, 4], [3]], [[1, 2, 3], [4]], 3),
([[2, 4, 5], [3]], [[2, 3, 5], [4]], 3)]
sage: sorted(G.vertices(sort=True))
sage: G.vertices(sort=True)
[[[1, 3, 4], [2]],
[[1, 2, 4], [3]],
[[2, 4, 5], [3]],
Expand Down Expand Up @@ -831,12 +831,12 @@ def dual_equivalence_class(self, index_set=None):
sage: T = crystals.Tableaux(['A',3], shape=[2,2])
sage: G = T(2,1,4,3).dual_equivalence_class()
sage: sorted(G.edges())
sage: G.edges(sort=True)
[([[1, 3], [2, 4]], [[1, 2], [3, 4]], 2),
([[1, 3], [2, 4]], [[1, 2], [3, 4]], 3)]
sage: T = crystals.Tableaux(['A',4], shape=[3,2])
sage: G = T(2,1,4,3,5).dual_equivalence_class()
sage: sorted(G.edges())
sage: G.edges(sort=True)
[([[1, 3, 5], [2, 4]], [[1, 3, 4], [2, 5]], 4),
([[1, 3, 5], [2, 4]], [[1, 2, 5], [3, 4]], 2),
([[1, 3, 5], [2, 4]], [[1, 2, 5], [3, 4]], 3),
Expand Down
8 changes: 4 additions & 4 deletions src/sage/categories/semigroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ def cayley_graph(self, side="right", simple=False, elements = None, generators =
sage: g = S.cayley_graph(simple=True)
sage: g.vertices(sort=True)
['a', 'ab', 'b', 'ba']
sage: g.edges()
sage: g.edges(sort=True)
[('a', 'ab', None), ('b', 'ba', None)]
::
sage: g = S.cayley_graph(side="left", simple=True)
sage: g.vertices(sort=True)
['a', 'ab', 'b', 'ba']
sage: g.edges()
sage: g.edges(sort=True)
[('a', 'ba', None), ('ab', 'ba', None), ('b', 'ab', None),
('ba', 'ab', None)]
Expand All @@ -258,7 +258,7 @@ def cayley_graph(self, side="right", simple=False, elements = None, generators =
sage: g = S.cayley_graph(side="twosided", simple=True)
sage: g.vertices(sort=True)
['a', 'ab', 'b', 'ba']
sage: g.edges()
sage: g.edges(sort=True)
[('a', 'ab', None), ('a', 'ba', None), ('ab', 'ba', None),
('b', 'ab', None), ('b', 'ba', None), ('ba', 'ab', None)]
Expand All @@ -267,7 +267,7 @@ def cayley_graph(self, side="right", simple=False, elements = None, generators =
sage: g = S.cayley_graph(side="twosided")
sage: g.vertices(sort=True)
['a', 'ab', 'b', 'ba']
sage: g.edges()
sage: g.edges(sort=True)
[('a', 'a', (0, 'left')), ('a', 'a', (0, 'right')), ('a', 'ab', (1, 'right')), ('a', 'ba', (1, 'left')), ('ab', 'ab', (0, 'left')), ('ab', 'ab', (0, 'right')), ('ab', 'ab', (1, 'right')), ('ab', 'ba', (1, 'left')), ('b', 'ab', (0, 'left')), ('b', 'b', (1, 'left')), ('b', 'b', (1, 'right')), ('b', 'ba', (0, 'right')), ('ba', 'ab', (0, 'left')), ('ba', 'ba', (0, 'right')), ('ba', 'ba', (1, 'left')), ('ba', 'ba', (1, 'right'))]
::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/simplicial_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def fundamental_group(self, simplify=True):
if not skel.is_connected():
graph = graph.subgraph(skel.base_point())

edges = [e[2] for e in graph.edges()]
edges = [e[2] for e in graph.edges(sort=True)]
spanning_tree = [e[2] for e in graph.min_spanning_tree()]
gens = [e for e in edges if e not in spanning_tree]

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/supercrystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def digraph(self, index_set=None):
sage: Q = crystals.Letters(['Q',3])
sage: G = Q.digraph(); G
Multi-digraph on 3 vertices
sage: G.edges()
sage: G.edges(sort=True)
[(1, 2, -1), (1, 2, 1), (2, 3, -2), (2, 3, 2)]
The edges of the crystal graph are by default colored using
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def quantum_bruhat_graph(self, index_set=()):
Parabolic Quantum Bruhat Graph of Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space) for nodes (1, 3): Digraph on 6 vertices
sage: g.vertices(sort=True)
[s2*s3*s1*s2, s3*s1*s2, s1*s2, s3*s2, s2, 1]
sage: g.edges()
sage: g.edges(sort=True)
[(s2*s3*s1*s2, s2, alpha[2]),
(s3*s1*s2, s2*s3*s1*s2, alpha[1] + alpha[2] + alpha[3]),
(s3*s1*s2, 1, alpha[2]),
Expand Down
2 changes: 1 addition & 1 deletion src/sage/coding/source_coding/huffman.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def _generate_edges(self, tree, parent="", bit=""):
sage: from sage.coding.source_coding.huffman import Huffman
sage: H = Huffman("Sage")
sage: T = H.tree()
sage: T.edges(labels=None) # indirect doctest
sage: T.edges(sort=True, labels=None) # indirect doctest
[('0', 'S: 00'), ('0', 'a: 01'), ('1', 'e: 10'), ('1', 'g: 11'), ('root', '0'), ('root', '1')]
"""
if parent == "":
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,11 @@ def graph(self, with_leaves=True):
sage: t1 = BinaryTree([[], [[], None]])
sage: t1.graph()
Digraph on 9 vertices
sage: t1.graph().edges()
sage: t1.graph().edges(sort=True)
[(0, 1, None), (0, 4, None), (1, 2, None), (1, 3, None), (4, 5, None), (4, 8, None), (5, 6, None), (5, 7, None)]
sage: t1.graph(with_leaves=False)
Digraph on 4 vertices
sage: t1.graph(with_leaves=False).edges()
sage: t1.graph(with_leaves=False).edges(sort=True)
[(0, 1, None), (0, 2, None), (2, 3, None)]
sage: t1 = BinaryTree()
Expand All @@ -744,7 +744,7 @@ def graph(self, with_leaves=True):
sage: t1 = BinaryTree([[], [[], []]])
sage: t1.graph(with_leaves=False)
Digraph on 5 vertices
sage: t1.graph(with_leaves=False).edges()
sage: t1.graph(with_leaves=False).edges(sort=True)
[(0, 1, None), (0, 2, None), (2, 3, None), (2, 4, None)]
"""
from sage.graphs.graph import DiGraph
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ClusterSeed(SageObject):
sage: T = ClusterSeed( S.quiver()._digraph ); T
A seed for a cluster algebra of rank 7
sage: T = ClusterSeed( S.quiver()._digraph.edges() ); T
sage: T = ClusterSeed( S.quiver()._digraph.edges(sort=True) ); T
A seed for a cluster algebra of rank 7
sage: S = ClusterSeed(['B',2]); S
Expand Down Expand Up @@ -2936,11 +2936,11 @@ def exchangeable_part(self):
EXAMPLES::
sage: S = ClusterSeed(['A',4])
sage: T = ClusterSeed( S.quiver().digraph().edges(), frozen=[3] )
sage: T.quiver().digraph().edges()
sage: T = ClusterSeed( S.quiver().digraph().edges(sort=True), frozen=[3] )
sage: T.quiver().digraph().edges(sort=True)
[(0, 1, (1, -1)), (2, 1, (1, -1)), (2, 3, (1, -1))]
sage: T.exchangeable_part().quiver().digraph().edges()
sage: T.exchangeable_part().quiver().digraph().edges(sort=True)
[(0, 1, (1, -1)), (2, 1, (1, -1))]
"""
Expand Down
Loading

0 comments on commit a9ecbc5

Please sign in to comment.