Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphs: make init_short_digraph always sort neighbors but without the extra log complexity #38427

Closed
60 changes: 33 additions & 27 deletions src/sage/algebras/lie_algebras/bgg_dual_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,18 @@ def degree_on_basis(self, m):
sage: M = g.verma_module(La[1] + La[4] - 1/3*La[5])
sage: Mc = M.dual()
sage: elt = Mc.an_element(); elt
f[-alpha[5]]^2*f[-alpha[4]]^2*f[-alpha[3]]^3*v[Lambda[1] + Lambda[4] - 1/3*Lambda[5]]^*
+ 2*f[-alpha[5]]*v[Lambda[1] + Lambda[4] - 1/3*Lambda[5]]^*
+ 3*f[-alpha[4]]*v[Lambda[1] + Lambda[4] - 1/3*Lambda[5]]^*
+ v[Lambda[1] + Lambda[4] - 1/3*Lambda[5]]^*
f[-alpha[2]]^2*f[-alpha[5]]^2*f[-alpha[3]]^3*v[Lambda[1] # 64-bit
+ Lambda[4] - 1/3*Lambda[5]]^* + 2*f[-alpha[2]]*v[Lambda[1] # 64-bit
+ Lambda[4] - 1/3*Lambda[5]]^* + 3*f[-alpha[5]]*v[Lambda[1] # 64-bit
+ Lambda[4] - 1/3*Lambda[5]]^* + v[Lambda[1] + Lambda[4] # 64-bit
- 1/3*Lambda[5]]^* # 64-bit
... # 32-bit
sage: [M.degree_on_basis(m) for m in elt.support()]
[Lambda[1] + 3*Lambda[2] - 2*Lambda[3] - 4/3*Lambda[5],
Lambda[1] + Lambda[4] - 1/3*Lambda[5],
Lambda[1] + Lambda[3] + Lambda[4] - 7/3*Lambda[5],
Lambda[1] + Lambda[3] - Lambda[4] - 1/3*Lambda[5]]
[3*Lambda[1] - Lambda[2] - 2*Lambda[3] + 4*Lambda[4] - 4/3*Lambda[5], # 64-bit
Lambda[1] + Lambda[4] - 1/3*Lambda[5], # 64-bit
2*Lambda[1] - 2*Lambda[2] + Lambda[3] + Lambda[4] - 1/3*Lambda[5], # 64-bit
Lambda[1] + Lambda[3] + Lambda[4] - 7/3*Lambda[5]] # 64-bit
... # 32-bit
"""
return self._module.degree_on_basis(m)

Expand Down Expand Up @@ -608,13 +611,13 @@ def __contains__(self, m):
1 True
f[-alpha[1]] True
f[-alpha[1] - alpha[2]] True
sage: gens = list(I.gens()); gens
[f[-alpha[2]],
sage: gens = list(sorted(I.gens())); gens
[f[-3*alpha[1] - 2*alpha[2]],
f[-3*alpha[1] - alpha[2]],
f[-2*alpha[1] - alpha[2]],
f[-alpha[1]],
f[-alpha[1] - alpha[2]],
f[-2*alpha[1] - alpha[2]],
f[-3*alpha[1] - alpha[2]],
f[-3*alpha[1] - 2*alpha[2]]]
f[-alpha[2]]]
sage: gens[1] in I
True
sage: gens[0] * gens[1] in I
Expand Down Expand Up @@ -896,24 +899,27 @@ def lift(self):
sage: g = LieAlgebra(QQ, cartan_type=['G', 2])
sage: La = g.cartan_type().root_system().weight_lattice().fundamental_weights()
sage: L = g.simple_module(La[1])
sage: [L.lift(b) for b in L.basis()] # long time
sage: sorted([L.lift(b) for b in L.basis()]) # long time
[v[Lambda[1]]^*,
f[-alpha[1]]*v[Lambda[1]]^*,
f[-alpha[2]]*f[-alpha[1]]*v[Lambda[1]]^* - f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*,
f[-alpha[1]]*f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*,
f[-alpha[2]]*f[-alpha[1]]^2*f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-alpha[2]]*f[-alpha[1]]*f[-2*alpha[1]
- alpha[2]]*v[Lambda[1]]^* + 1/2*f[-alpha[2]]*f[-3*alpha[1]
- alpha[2]]*v[Lambda[1]]^* - f[-alpha[1]
- alpha[2]]*f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ 1/2*f[-3*alpha[1] - 2*alpha[2]]*v[Lambda[1]]^*,
f[-alpha[1]]^2*f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-alpha[1]]*f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ 1/2*f[-3*alpha[1] - alpha[2]]*v[Lambda[1]]^*,
f[-alpha[2]]*f[-alpha[1]]^2*f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-alpha[2]]*f[-alpha[1]]*f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ 1/2*f[-alpha[2]]*f[-3*alpha[1] - alpha[2]]*v[Lambda[1]]^*
- f[-alpha[1] - alpha[2]]*f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ 1/2*f[-3*alpha[1] - 2*alpha[2]]*v[Lambda[1]]^*,
f[-alpha[1]]*f[-alpha[1] - alpha[2]]*f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*
- 1/2*f[-alpha[1]]*f[-3*alpha[1] - 2*alpha[2]]*v[Lambda[1]]^*
- 1/2*f[-alpha[1] - alpha[2]]*f[-3*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-2*alpha[1] - alpha[2]]^2*v[Lambda[1]]^*]
f[-alpha[1]]*f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-2*alpha[1] - alpha[2]]*v[Lambda[1]]^*,
f[-alpha[1]]*f[-alpha[1] - alpha[2]]*f[-2*alpha[1]
- alpha[2]]*v[Lambda[1]]^* - 1/2*f[-alpha[1]]*f[-3*alpha[1]
- 2*alpha[2]]*v[Lambda[1]]^* - 1/2*f[-alpha[1]
- alpha[2]]*f[-3*alpha[1] - alpha[2]]*v[Lambda[1]]^*
+ f[-2*alpha[1] - alpha[2]]^2*v[Lambda[1]]^*,
f[-alpha[1]]*v[Lambda[1]]^*,
f[-alpha[2]]*f[-alpha[1]]*v[Lambda[1]]^*
- f[-alpha[1] - alpha[2]]*v[Lambda[1]]^*]
"""
return self.module_morphism(self._lift_on_basis, codomain=self._ambient, unitriangular="upper")

Expand Down
13 changes: 5 additions & 8 deletions src/sage/algebras/lie_algebras/classical_lie_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1996,14 +1996,11 @@ def degree_on_basis(self, m):
EXAMPLES::

sage: L = LieAlgebra(QQ, cartan_type=['G', 2])
sage: [L.degree_on_basis(m) for m in L.basis().keys()]
[alpha[2], alpha[1], alpha[1] + alpha[2],
2*alpha[1] + alpha[2], 3*alpha[1] + alpha[2],
3*alpha[1] + 2*alpha[2],
0, 0,
-alpha[2], -alpha[1], -alpha[1] - alpha[2],
-2*alpha[1] - alpha[2], -3*alpha[1] - alpha[2],
-3*alpha[1] - 2*alpha[2]]
sage: sorted([L.degree_on_basis(m) for m in L.basis().keys()])
[0, 0, -3*alpha[1] - 2*alpha[2], -3*alpha[1] - alpha[2],
-2*alpha[1] - alpha[2], -alpha[1], -alpha[1] - alpha[2], alpha[1],
alpha[1] + alpha[2], 2*alpha[1] + alpha[2], 3*alpha[1] + alpha[2],
3*alpha[1] + 2*alpha[2], -alpha[2], alpha[2]]
"""
if m.parent() is self._Q:
return m
Expand Down
7 changes: 4 additions & 3 deletions src/sage/algebras/lie_algebras/lie_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,10 @@ cdef class UntwistedAffineLieAlgebraElement(Element):
sage: L = lie_algebras.Affine(QQ, ['B', 3, 1])
sage: elt = L.an_element()
sage: elt._repr_generic(str, str, lambda t: "T^{}".format(t), '.', '(x)')
'(E[alpha[3]] + E[alpha[2]] + E[alpha[1]] + h1 + h2 + h3 + E[-alpha[3]]
+ E[-alpha[2]] + E[-alpha[1]])(x)T^0 + (E[-alpha[1] - 2*alpha[2]
- 2*alpha[3]])(x)T^1 + (E[alpha[1] + 2*alpha[2] + 2*alpha[3]])(x)T^-1 + c + d'
'(E[alpha[3]] + E[alpha[2]] + E[alpha[1]] + h1 + h2 + h3 + E[-alpha[3]] # 64-bit
+ E[-alpha[2]] + E[-alpha[1]])(x)T^0 + (E[-alpha[1] - 2*alpha[2] # 64-bit
- 2*alpha[3]])(x)T^1 + (E[alpha[1] + 2*alpha[2] + 2*alpha[3]])(x)T^-1 + c + d' # 64-bit
... # 32-bit
"""
ret = style('')
mult = style(mult)
Expand Down
17 changes: 9 additions & 8 deletions src/sage/algebras/lie_algebras/poincare_birkhoff_witt.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,13 @@ def casimir_element(self, order=2, *args, **kwds):
sage: L = LieAlgebra(QQ, cartan_type=['G', 2])
sage: U = L.pbw_basis()
sage: C = U.casimir_element(); C
1/4*PBW[alpha[2]]*PBW[-alpha[2]] + 1/12*PBW[alpha[1]]*PBW[-alpha[1]]
+ 1/12*PBW[alpha[1] + alpha[2]]*PBW[-alpha[1] - alpha[2]] + 1/12*PBW[2*alpha[1] + alpha[2]]*PBW[-2*alpha[1] - alpha[2]]
+ 1/4*PBW[3*alpha[1] + alpha[2]]*PBW[-3*alpha[1] - alpha[2]]
+ 1/4*PBW[3*alpha[1] + 2*alpha[2]]*PBW[-3*alpha[1] - 2*alpha[2]]
+ 1/12*PBW[alphacheck[1]]^2 + 1/4*PBW[alphacheck[1]]*PBW[alphacheck[2]]
+ 1/4*PBW[alphacheck[2]]^2 - 5/12*PBW[alphacheck[1]] - 3/4*PBW[alphacheck[2]]
1/4*PBW[alpha[2]]*PBW[-alpha[2]] + 1/12*PBW[alpha[1]]*PBW[-alpha[1]] # 64-bit
+ 1/12*PBW[alpha[1] + alpha[2]]*PBW[-alpha[1] - alpha[2]] + 1/12*PBW[2*alpha[1] + alpha[2]]*PBW[-2*alpha[1] - alpha[2]] # 64-bit
+ 1/4*PBW[3*alpha[1] + alpha[2]]*PBW[-3*alpha[1] - alpha[2]] # 64-bit
+ 1/4*PBW[3*alpha[1] + 2*alpha[2]]*PBW[-3*alpha[1] - 2*alpha[2]] # 64-bit
+ 1/12*PBW[alphacheck[1]]^2 + 1/4*PBW[alphacheck[1]]*PBW[alphacheck[2]] # 64-bit
+ 1/4*PBW[alphacheck[2]]^2 - 5/12*PBW[alphacheck[1]] - 3/4*PBW[alphacheck[2]] # 64-bit
... # 32-bit
sage: all(g * C == C * g for g in U.algebra_generators())
True

Expand Down Expand Up @@ -767,8 +768,8 @@ def _transpose_on_basis(self, m):
sage: f1, f2, f3, f4, f5, f6 = U.f()
sage: e1, e2, e3, e4, e5, e6 = U.e()
sage: elt = e1 * e4^2 * f1 * f2^3
sage: U._transpose_on_basis(elt.support()[0])
PBW[alpha[2]]^3*PBW[alpha[1]]*PBW[-alpha[4]]^2*PBW[-alpha[1]]
sage: U._transpose_on_basis(elt.support()[0]) == e2^3*e1*f1*f4^2
True
"""
I = self._indices
basis_mapping = self._g._transpose_basis_mapping
Expand Down
5 changes: 3 additions & 2 deletions src/sage/algebras/lie_algebras/verma_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,9 @@ def singular_vector(self):
sage: Mp = L.verma_module(mu)
sage: H = Hom(Mp, M)
sage: v = H.singular_vector(); v
f[-alpha[2]]*f[-alpha[1]]^3*v[Lambda[1] - Lambda[3]]
+ 3*f[-alpha[1]]^2*f[-alpha[1] - alpha[2]]*v[Lambda[1] - Lambda[3]]
f[-alpha[2]]*f[-alpha[1]]^3*v[Lambda[1] - Lambda[3]] # 64-bit
+ 3*f[-alpha[1]]^2*f[-alpha[1] - alpha[2]]*v[Lambda[1] - Lambda[3]] # 64-bit
... # 32-bit
sage: v.degree() == Mp.highest_weight()
True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ def _repr_(self):

sage: R = lie_conformal_algebras.Affine(QQ, 'B3')
sage: R.2.T()+3*R.3
TB[alpha[1]] + 3*B[alpha[2] + alpha[3]]
TB[alpha[1]] + 3*B[alpha[2] + alpha[3]] # 64-bit
... # 32-bit
"""
if self.is_zero():
return "0"
Expand Down
12 changes: 6 additions & 6 deletions src/sage/categories/regular_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,13 +838,13 @@ def dual_equivalence_class(self, index_set=None):
([[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: 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),
sage: G.edges(sort=True,sort_vertices=True)
[([[1, 3, 4], [2, 5]], [[1, 3, 5], [2, 4]], 4),
([[1, 3, 4], [2, 5]], [[1, 2, 4], [3, 5]], 2),
([[1, 2, 4], [3, 5]], [[1, 2, 3], [4, 5]], 3),
([[1, 2, 4], [3, 5]], [[1, 2, 3], [4, 5]], 4)]
([[1, 2, 5], [3, 4]], [[1, 3, 5], [2, 4]], 2),
([[1, 2, 5], [3, 4]], [[1, 3, 5], [2, 4]], 3),
([[1, 2, 3], [4, 5]], [[1, 2, 4], [3, 5]], 3),
([[1, 2, 3], [4, 5]], [[1, 2, 4], [3, 5]], 4)]
"""
if index_set is None:
index_set = self.index_set()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/growth.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,7 @@ def _check_duality(self, n):
...
ValueError: D U - U D differs from 1 I for vertex [2]:
D U = [[2]]
U D + 1 I = [[1, 1], [2], [2]]
U D + 1 I = [[2], [1, 1], [2]]
"""
if self.has_multiple_edges:
def check_vertex(w, P, Q):
Expand Down Expand Up @@ -1841,8 +1841,8 @@ def Q_graph(self, n):
sage: Q = Domino.Q_graph(3); Q
Finite poset containing 8 elements

sage: Q.upper_covers(Partition([1,1]))
[[1, 1, 1, 1], [3, 1], [2, 2]]
sage: sorted(Q.upper_covers(Partition([1,1])))
[[1, 1, 1, 1], [2, 2], [3, 1]]
"""
if self.has_multiple_edges:
D = DiGraph([(x, y, e) for k in range(n - 1)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4785,12 +4785,12 @@ def permutation_poset(self):
EXAMPLES::

sage: # needs sage.combinat sage.graphs
sage: Permutation([3,1,5,4,2]).permutation_poset().cover_relations()
[[(2, 1), (5, 2)],
sage: sorted(Permutation([3,1,5,4,2]).permutation_poset().cover_relations())
[[(1, 3), (3, 5)],
[(1, 3), (4, 4)],
[(2, 1), (3, 5)],
[(2, 1), (4, 4)],
[(1, 3), (3, 5)],
[(1, 3), (4, 4)]]
[(2, 1), (5, 2)]]
sage: Permutation([]).permutation_poset().cover_relations()
[]
sage: Permutation([1,3,2]).permutation_poset().cover_relations()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/posets/hasse_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,9 @@ def moebius_function_matrix(self, algorithm='cython'):
True
sage: H = posets.TamariLattice(3)._hasse_diagram
sage: M = H.moebius_function_matrix('matrix'); M
[ 1 -1 -1 0 1]
[ 0 1 0 0 -1]
[ 0 0 1 -1 0]
[ 1 -1 0 -1 1]
[ 0 1 -1 0 0]
[ 0 0 1 0 -1]
[ 0 0 0 1 -1]
[ 0 0 0 0 1]
sage: _ = H.__dict__.pop('_moebius_function_matrix')
Expand Down
8 changes: 4 additions & 4 deletions src/sage/combinat/posets/lattices.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ def submeetsemilattice(self, elms):
sage: L = posets.DivisorLattice(1000)
sage: L_ = L.submeetsemilattice([200, 250, 125]); L_
Finite meet-semilattice containing 5 elements
sage: L_.list()
[25, 50, 200, 125, 250]
sage: sorted(L_.list())
[25, 50, 125, 200, 250]

.. SEEALSO::

Expand Down Expand Up @@ -3159,8 +3159,8 @@ def sublattice(self, elms):
EXAMPLES::

sage: L = LatticePoset(([], [[1,2],[1,17],[1,8],[2,3],[2,22],[2,5],[2,7],[17,22],[17,13],[8,7],[8,13],[3,16],[3,9],[22,16],[22,18],[22,10],[5,18],[5,14],[7,9],[7,14],[7,10],[13,10],[16,6],[16,19],[9,19],[18,6],[18,33],[14,33],[10,19],[10,33],[6,4],[19,4],[33,4]]))
sage: L.sublattice([14, 13, 22]).list()
[1, 2, 8, 7, 14, 17, 13, 22, 10, 33]
sage: sorted(L.sublattice([14, 13, 22]).list())
[1, 2, 7, 8, 10, 13, 14, 17, 22, 33]

sage: L = posets.BooleanLattice(3)
sage: L.sublattice([3,5,6,7])
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/posets/poset_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ def YoungsLattice(n):

sage: P = posets.YoungsLattice(3); P
Finite meet-semilattice containing 7 elements
sage: P.cover_relations()
sage: sorted(P.cover_relations())
[[[], [1]],
[[1], [1, 1]],
[[1], [2]],
Expand Down Expand Up @@ -1488,7 +1488,7 @@ def YoungsLatticePrincipalOrderIdeal(lam):
sage: P = posets.YoungsLatticePrincipalOrderIdeal(Partition([2,2]))
sage: P
Finite lattice containing 6 elements
sage: P.cover_relations()
sage: sorted(P.cover_relations())
[[[], [1]],
[[1], [1, 1]],
[[1], [2]],
Expand Down
18 changes: 9 additions & 9 deletions src/sage/combinat/posets/posets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6335,8 +6335,8 @@ def graphviz_string(self, graph_string='graph', edge_string='--'):
sage: P = Poset({'a':['b'],'b':['d'],'c':['d'],'d':['f'],'e':['f'],'f':[]})
sage: print(P.graphviz_string())
graph {
"f";"d";"b";"a";"c";"e";
"f"--"e";"d"--"c";"b"--"a";"d"--"b";"f"--"d";
"f";"e";"d";"c";"b";"a";
"b"--"a";"d"--"b";"d"--"c";"f"--"d";"f"--"e";
}
"""
s = '%s {\n' % graph_string
Expand All @@ -6359,8 +6359,8 @@ def subposet(self, elements):
....: 'd': ['f'], 'e': ['f']})
sage: Q = P.subposet(['a', 'b', 'f']); Q
Finite poset containing 3 elements
sage: Q.cover_relations()
[['b', 'f'], ['a', 'f']]
sage: sorted(Q.cover_relations())
[['a', 'f'], ['b', 'f']]

A subposet of a non-facade poset is again a non-facade poset::

Expand Down Expand Up @@ -6640,8 +6640,8 @@ def order_filter(self, elements):
EXAMPLES::

sage: P = Poset((divisors(1000), attrcall("divides")))
sage: P.order_filter([20, 25])
[20, 40, 25, 50, 100, 200, 125, 250, 500, 1000]
sage: sorted(P.order_filter([20, 25]))
[20, 25, 40, 50, 100, 125, 200, 250, 500, 1000]

.. SEEALSO::

Expand Down Expand Up @@ -6672,7 +6672,7 @@ def order_ideal(self, elements):
EXAMPLES::

sage: P = Poset((divisors(1000), attrcall("divides")))
sage: P.order_ideal([20, 25])
sage: sorted(P.order_ideal([20, 25]))
[1, 2, 4, 5, 10, 20, 25]

.. SEEALSO::
Expand Down Expand Up @@ -6778,7 +6778,7 @@ def closed_interval(self, x, y):
EXAMPLES::

sage: P = Poset((divisors(1000), attrcall("divides")))
sage: P.closed_interval(2, 100)
sage: sorted(P.closed_interval(2, 100))
[2, 4, 10, 20, 50, 100]

.. SEEALSO::
Expand Down Expand Up @@ -6806,7 +6806,7 @@ def open_interval(self, x, y):
EXAMPLES::

sage: P = Poset((divisors(1000), attrcall("divides")))
sage: P.open_interval(2, 100)
sage: sorted(P.open_interval(2, 100))
[4, 10, 20, 50]

.. SEEALSO::
Expand Down
Loading
Loading