diff --git a/src/sage/combinat/posets/elements.py b/src/sage/combinat/posets/elements.py index 4788246cd1d..4cfb0b28ae0 100644 --- a/src/sage/combinat/posets/elements.py +++ b/src/sage/combinat/posets/elements.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.modules r""" Elements of posets, lattices, semilattices, etc. """ @@ -78,13 +79,13 @@ def _latex_(self): EXAMPLES:: - sage: m = matrix(2, [1,2,3,4]) # optional - sage.modules - sage: m.set_immutable() # optional - sage.modules - sage: P = Poset(([m],[]), facade=False) # optional - sage.modules - sage: [e] = P # optional - sage.modules - sage: type(e) # optional - sage.modules + sage: m = matrix(2, [1,2,3,4]) + sage: m.set_immutable() + sage: P = Poset(([m],[]), facade=False) + sage: [e] = P + sage: type(e) - sage: latex(e) #indirect doctest # optional - sage.modules + sage: latex(e) #indirect doctest \left(\begin{array}{rr} 1 & 2 \\ 3 & 4 @@ -244,13 +245,13 @@ def __mul__(self, other): EXAMPLES:: sage: D = posets.DiamondPoset(5, facade=False) - sage: D(1) * D(2) # optional - sage.modules + sage: D(1) * D(2) 0 - sage: D(1) * D(1) # optional - sage.modules + sage: D(1) * D(1) 1 - sage: D(1) * D(0) # optional - sage.modules + sage: D(1) * D(0) 0 - sage: D(1) * D(4) # optional - sage.modules + sage: D(1) * D(4) 1 """ return self.parent().meet(self, other) @@ -264,13 +265,13 @@ def __add__(self, other): EXAMPLES:: sage: D = posets.DiamondPoset(5,facade=False) - sage: D(1) + D(2) # optional - sage.modules + sage: D(1) + D(2) 4 - sage: D(1) + D(1) # optional - sage.modules + sage: D(1) + D(1) 1 - sage: D(1) + D(4) # optional - sage.modules + sage: D(1) + D(4) 4 - sage: D(1) + D(0) # optional - sage.modules + sage: D(1) + D(0) 1 """ return self.parent().join(self, other) diff --git a/src/sage/combinat/posets/poset_examples.py b/src/sage/combinat/posets/poset_examples.py index f9a5d793dfa..f565c7f9903 100644 --- a/src/sage/combinat/posets/poset_examples.py +++ b/src/sage/combinat/posets/poset_examples.py @@ -1,9 +1,10 @@ +# sage.doctest: needs sage.combinat sage.modules r""" Catalog of posets and lattices Some common posets can be accessed through the ``posets.`` object:: - sage: posets.PentagonPoset() # optional - sage.modules + sage: posets.PentagonPoset() Finite lattice containing 5 elements Moreover, the set of all posets of order `n` is represented by ``Posets(n)``:: @@ -238,9 +239,9 @@ def BooleanLattice(n, facade=None, use_subsets=False): Check the corner cases:: - sage: list(posets.BooleanLattice(0, use_subsets=True)) # optional - sage.modules + sage: list(posets.BooleanLattice(0, use_subsets=True)) [{}] - sage: list(posets.BooleanLattice(1, use_subsets=True)) # optional - sage.modules + sage: list(posets.BooleanLattice(1, use_subsets=True)) [{}, {1}] """ n = check_int(n) @@ -382,22 +383,22 @@ def PentagonPoset(facade=None): EXAMPLES:: - sage: P = posets.PentagonPoset(); P # optional - sage.modules + sage: P = posets.PentagonPoset(); P Finite lattice containing 5 elements - sage: P.cover_relations() # optional - sage.modules + sage: P.cover_relations() [[0, 1], [0, 2], [1, 4], [2, 3], [3, 4]] TESTS: This is smallest lattice that is not modular:: - sage: P.is_modular() # optional - sage.modules + sage: P.is_modular() False This poset and the :meth:`DiamondPoset` are the two smallest lattices which are not distributive:: - sage: P.is_distributive() # optional - sage.modules + sage: P.is_distributive() False sage: posets.DiamondPoset(5).is_distributive() False @@ -535,9 +536,9 @@ def IntegerPartitions(n): EXAMPLES:: - sage: P = posets.IntegerPartitions(7); P # optional - sage.combinat + sage: P = posets.IntegerPartitions(7); P Finite poset containing 15 elements - sage: len(P.cover_relations()) # optional - sage.combinat + sage: len(P.cover_relations()) 28 """ def lower_covers(partition): @@ -573,9 +574,9 @@ def RestrictedIntegerPartitions(n): EXAMPLES:: - sage: P = posets.RestrictedIntegerPartitions(7); P # optional - sage.combinat + sage: P = posets.RestrictedIntegerPartitions(7); P Finite poset containing 15 elements - sage: len(P.cover_relations()) # optional - sage.combinat + sage: len(P.cover_relations()) 17 """ @@ -617,9 +618,9 @@ def IntegerPartitionsDominanceOrder(n): EXAMPLES:: - sage: P = posets.IntegerPartitionsDominanceOrder(6); P # optional - sage.combinat + sage: P = posets.IntegerPartitionsDominanceOrder(6); P Finite lattice containing 11 elements - sage: P.cover_relations() # optional - sage.combinat + sage: P.cover_relations() [[[1, 1, 1, 1, 1, 1], [2, 1, 1, 1, 1]], [[2, 1, 1, 1, 1], [2, 2, 1, 1]], [[2, 2, 1, 1], [2, 2, 2]], @@ -652,22 +653,22 @@ def PowerPoset(n): EXAMPLES:: - sage: P3 = posets.PowerPoset(3); P3 # optional - sage.modules + sage: P3 = posets.PowerPoset(3); P3 Finite meet-semilattice containing 19 elements - sage: all(P.is_chain() for P in P3.maximal_elements()) # optional - sage.modules + sage: all(P.is_chain() for P in P3.maximal_elements()) True TESTS:: - sage: P0 = posets.PowerPoset(0); P0 # optional - sage.modules + sage: P0 = posets.PowerPoset(0); P0 Finite meet-semilattice containing 1 elements - sage: P0[0] # optional - sage.modules + sage: P0[0] Finite poset containing 0 elements - sage: P1 = posets.PowerPoset(1); P1 # optional - sage.modules + sage: P1 = posets.PowerPoset(1); P1 Finite meet-semilattice containing 1 elements - sage: P1[0] # optional - sage.modules + sage: P1[0] Finite poset containing 1 elements - sage: P1[0][0] # optional - sage.modules + sage: P1[0][0] 0 """ # Todo: Make this faster. @@ -697,22 +698,22 @@ def ProductOfChains(chain_lengths, facade=None): EXAMPLES:: - sage: P = posets.ProductOfChains([2, 2]); P # optional - sage.modules + sage: P = posets.ProductOfChains([2, 2]); P Finite lattice containing 4 elements - sage: P.linear_extension() # optional - sage.modules + sage: P.linear_extension() [(0, 0), (0, 1), (1, 0), (1, 1)] - sage: P.upper_covers((0,0)) # optional - sage.modules + sage: P.upper_covers((0,0)) [(0, 1), (1, 0)] - sage: P.lower_covers((1,1)) # optional - sage.modules + sage: P.lower_covers((1,1)) [(0, 1), (1, 0)] TESTS:: - sage: P = posets.ProductOfChains([]); P # optional - sage.modules + sage: P = posets.ProductOfChains([]); P Finite lattice containing 0 elements - sage: P = posets.ProductOfChains([3, 0, 1]); P # optional - sage.modules + sage: P = posets.ProductOfChains([3, 0, 1]); P Finite lattice containing 0 elements - sage: P = posets.ProductOfChains([1,1,1,1]); P # optional - sage.modules + sage: P = posets.ProductOfChains([1,1,1,1]); P Finite lattice containing 1 elements """ try: @@ -831,12 +832,12 @@ def RandomLattice(n, p, properties=None): EXAMPLES:: sage: set_random_seed(0) # Results are reproducible - sage: L = posets.RandomLattice(8, 0.995); L # optional - sage.modules + sage: L = posets.RandomLattice(8, 0.995); L Finite lattice containing 8 elements - sage: L.cover_relations() # optional - sage.modules + sage: L.cover_relations() [[7, 6], [7, 3], [7, 1], ..., [5, 4], [2, 4], [1, 4], [0, 4]] - sage: L = posets.RandomLattice(10, 0, properties=['dismantlable']) # optional - sage.modules - sage: L.is_dismantlable() # optional - sage.modules + sage: L = posets.RandomLattice(10, 0, properties=['dismantlable']) + sage: L.is_dismantlable() True .. SEEALSO:: :meth:`RandomPoset` @@ -858,7 +859,7 @@ def RandomLattice(n, p, properties=None): ... ValueError: unknown value junk for 'properties' - sage: posets.RandomLattice(0, 0.5) # optional - sage.modules + sage: posets.RandomLattice(0, 0.5) Finite lattice containing 0 elements """ from copy import copy @@ -941,7 +942,7 @@ def SetPartitions(n): EXAMPLES:: - sage: posets.SetPartitions(4) # optional - sage.combinat + sage: posets.SetPartitions(4) Finite lattice containing 15 elements """ from sage.combinat.set_partition import SetPartitions @@ -981,19 +982,19 @@ def SSTPoset(s, f=None): EXAMPLES:: - sage: posets.SSTPoset([2,1]) # optional - sage.combinat + sage: posets.SSTPoset([2,1]) Finite lattice containing 8 elements - sage: posets.SSTPoset([2,1],4) # optional - sage.combinat + sage: posets.SSTPoset([2,1],4) Finite lattice containing 20 elements - sage: posets.SSTPoset([2,1],2).cover_relations() # optional - sage.combinat + sage: posets.SSTPoset([2,1],2).cover_relations() [[[[1, 1], [2]], [[1, 2], [2]]]] - sage: posets.SSTPoset([3,2]).bottom() # long time (6s on sage.math, 2012) # optional - sage.combinat + sage: posets.SSTPoset([3,2]).bottom() # long time (6s on sage.math, 2012) [[1, 1, 1], [2, 2]] - sage: posets.SSTPoset([3,2],4).maximal_elements() # optional - sage.combinat + sage: posets.SSTPoset([3,2],4).maximal_elements() [[[3, 3, 4], [4, 4]]] """ from sage.combinat.tableau import SemistandardTableaux @@ -1202,11 +1203,11 @@ def TetrahedralPoset(n, *colors, **labels): sage: posets.TetrahedralPoset(4,'green','red','yellow','silver','blue','orange', labels='integers') Finite poset containing 10 elements - sage: A = AlternatingSignMatrices(3) # optional - sage.combinat sage.modules - sage: p = A.lattice() # optional - sage.combinat sage.modules - sage: ji = p.join_irreducibles_poset() # optional - sage.combinat sage.modules - sage: tet = posets.TetrahedralPoset(3, 'green','yellow','blue','orange') # optional - sage.combinat sage.modules - sage: ji.is_isomorphic(tet) # optional - sage.combinat sage.modules + sage: A = AlternatingSignMatrices(3) + sage: p = A.lattice() + sage: ji = p.join_irreducibles_poset() + sage: tet = posets.TetrahedralPoset(3, 'green','yellow','blue','orange') + sage: ji.is_isomorphic(tet) True TESTS:: @@ -1276,12 +1277,12 @@ def CoxeterGroupAbsoluteOrderPoset(W, use_reduced_words=True): EXAMPLES:: - sage: W = CoxeterGroup(['B', 3]) # optional - sage.combinat sage.groups - sage: posets.CoxeterGroupAbsoluteOrderPoset(W) # optional - sage.combinat sage.groups + sage: W = CoxeterGroup(['B', 3]) # needs sage.groups + sage: posets.CoxeterGroupAbsoluteOrderPoset(W) # needs sage.groups Finite poset containing 48 elements - sage: W = WeylGroup(['B', 2], prefix='s') # optional - sage.combinat sage.groups - sage: posets.CoxeterGroupAbsoluteOrderPoset(W, False) # optional - sage.combinat sage.groups + sage: W = WeylGroup(['B', 2], prefix='s') # needs sage.groups + sage: posets.CoxeterGroupAbsoluteOrderPoset(W, False) # needs sage.groups Finite poset containing 8 elements """ if use_reduced_words: @@ -1300,12 +1301,12 @@ def NoncrossingPartitions(W): EXAMPLES:: - sage: W = CoxeterGroup(['A', 3]) # optional - sage.combinat sage.groups - sage: posets.NoncrossingPartitions(W) # optional - sage.combinat sage.groups + sage: W = CoxeterGroup(['A', 3]) # needs sage.groups + sage: posets.NoncrossingPartitions(W) # needs sage.groups Finite lattice containing 14 elements - sage: W = WeylGroup(['B', 2], prefix='s') # optional - sage.combinat sage.groups - sage: posets.NoncrossingPartitions(W) # optional - sage.combinat sage.groups + sage: W = WeylGroup(['B', 2], prefix='s') # needs sage.groups + sage: posets.NoncrossingPartitions(W) # needs sage.groups Finite lattice containing 6 elements """ return W.noncrossing_partition_lattice() @@ -1331,11 +1332,11 @@ def SymmetricGroupAbsoluteOrderPoset(n, labels="permutations"): EXAMPLES:: - sage: posets.SymmetricGroupAbsoluteOrderPoset(4) # optional - sage.groups + sage: posets.SymmetricGroupAbsoluteOrderPoset(4) # needs sage.groups Finite poset containing 24 elements - sage: posets.SymmetricGroupAbsoluteOrderPoset(3, labels="cycles") # optional - sage.groups + sage: posets.SymmetricGroupAbsoluteOrderPoset(3, labels="cycles") # needs sage.groups Finite poset containing 6 elements - sage: posets.SymmetricGroupAbsoluteOrderPoset(3, labels="reduced_words") # optional - sage.groups + sage: posets.SymmetricGroupAbsoluteOrderPoset(3, labels="reduced_words") # needs sage.groups Finite poset containing 6 elements """ from sage.groups.perm_gps.permgroup_named import SymmetricGroup @@ -1380,7 +1381,7 @@ def UpDownPoset(n, m=1): Fibonacci numbers as the number of antichains of a poset:: - sage: [len(posets.UpDownPoset(n).antichains().list()) for n in range(6)] # optional - sage.combinat + sage: [len(posets.UpDownPoset(n).antichains().list()) for n in range(6)] [1, 2, 3, 5, 8, 13] TESTS:: @@ -1414,13 +1415,13 @@ def YoungDiagramPoset(lam, dual=False): EXAMPLES:: - sage: P = posets.YoungDiagramPoset(Partition([2, 2])); P # optional - sage.combinat + sage: P = posets.YoungDiagramPoset(Partition([2, 2])); P Finite meet-semilattice containing 4 elements - sage: sorted(P.cover_relations()) # optional - sage.combinat + sage: sorted(P.cover_relations()) [[(0, 0), (0, 1)], [(0, 0), (1, 0)], [(0, 1), (1, 1)], [(1, 0), (1, 1)]] - sage: posets.YoungDiagramPoset([3, 2], dual=True) # optional - sage.combinat + sage: posets.YoungDiagramPoset([3, 2], dual=True) Finite join-semilattice containing 5 elements """ from sage.combinat.partition import Partition @@ -1460,9 +1461,9 @@ def YoungsLattice(n): EXAMPLES:: - sage: P = posets.YoungsLattice(3); P # optional - sage.combinat + sage: P = posets.YoungsLattice(3); P Finite meet-semilattice containing 7 elements - sage: P.cover_relations() # optional - sage.combinat + sage: P.cover_relations() [[[], [1]], [[1], [1, 1]], [[1], [2]], @@ -1488,10 +1489,10 @@ def YoungsLatticePrincipalOrderIdeal(lam): EXAMPLES:: - sage: P = posets.YoungsLatticePrincipalOrderIdeal(Partition([2,2])) # optional - sage.combinat - sage: P # optional - sage.combinat + sage: P = posets.YoungsLatticePrincipalOrderIdeal(Partition([2,2])) + sage: P Finite lattice containing 6 elements - sage: P.cover_relations() # optional - sage.combinat + sage: P.cover_relations() [[[], [1]], [[1], [1, 1]], [[1], [2]], @@ -1527,16 +1528,16 @@ def YoungFibonacci(n): EXAMPLES:: - sage: Y5 = posets.YoungFibonacci(5); Y5 # optional - sage.combinat + sage: Y5 = posets.YoungFibonacci(5); Y5 Finite meet-semilattice containing 20 elements - sage: sorted(Y5.upper_covers(Word('211'))) # optional - sage.combinat + sage: sorted(Y5.upper_covers(Word('211'))) [word: 1211, word: 2111, word: 221] TESTS:: - sage: posets.YoungFibonacci(0) # optional - sage.combinat + sage: posets.YoungFibonacci(0) Finite meet-semilattice containing 1 elements - sage: posets.YoungFibonacci(1) # optional - sage.combinat + sage: posets.YoungFibonacci(1) Finite meet-semilattice containing 2 elements """ from sage.combinat.posets.lattices import FiniteMeetSemilattice @@ -1616,9 +1617,9 @@ def PermutationPattern(n): EXAMPLES:: - sage: P4 = posets.PermutationPattern(4); P4 # optional - sage.combinat + sage: P4 = posets.PermutationPattern(4); P4 Finite poset containing 33 elements - sage: sorted(P4.lower_covers(Permutation([2,4,1,3]))) # optional - sage.combinat + sage: sorted(P4.lower_covers(Permutation([2,4,1,3]))) [[1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2]] .. SEEALSO:: @@ -1627,9 +1628,9 @@ def PermutationPattern(n): TESTS:: - sage: posets.PermutationPattern(1) # optional - sage.combinat + sage: posets.PermutationPattern(1) Finite poset containing 1 elements - sage: posets.PermutationPattern(2) # optional - sage.combinat + sage: posets.PermutationPattern(2) Finite poset containing 3 elements """ n = check_int(n, 1) @@ -1660,9 +1661,9 @@ def PermutationPatternInterval(bottom, top): sage: t = Permutation([2,3,1]) sage: b = Permutation([4,6,2,3,5,1]) - sage: R = posets.PermutationPatternInterval(t, b); R # optional - sage.combinat + sage: R = posets.PermutationPatternInterval(t, b); R Finite poset containing 14 elements - sage: R.moebius_function(R.bottom(),R.top()) # optional - sage.combinat + sage: R.moebius_function(R.bottom(),R.top()) -4 .. SEEALSO:: @@ -1673,7 +1674,7 @@ def PermutationPatternInterval(bottom, top): TESTS:: sage: p = Permutation([1]) - sage: posets.PermutationPatternInterval(p, p) # optional - sage.combinat + sage: posets.PermutationPatternInterval(p, p) Finite poset containing 1 elements """ P = Permutations() @@ -1732,7 +1733,7 @@ def PermutationPatternOccurrenceInterval(bottom, top, pos): sage: t = Permutation([3,2,1]) sage: b = Permutation([6,3,4,5,2,1]) - sage: A = posets.PermutationPatternOccurrenceInterval(t, b, (0,2,4)); A # optional - sage.combinat + sage: A = posets.PermutationPatternOccurrenceInterval(t, b, (0,2,4)); A Finite poset containing 8 elements .. SEEALSO:: @@ -1818,11 +1819,11 @@ def MobilePoset(ribbon, hangers, anchor=None): sage: len(M.cover_relations()) 7 - sage: P = posets.MobilePoset(posets.RibbonPoset(7, [1,3]), # optional - sage.combinat + sage: P = posets.MobilePoset(posets.RibbonPoset(7, [1,3]), ....: {1: [posets.YoungDiagramPoset([3, 2], dual=True)], ....: 3: [posets.DoubleTailedDiamond(6)]}, ....: anchor=(4, 2, posets.ChainPoset(6))) - sage: len(P.cover_relations()) # optional - sage.combinat + sage: len(P.cover_relations()) 33 """ elements = [] @@ -2039,8 +2040,8 @@ def _random_distributive_lattice(n): EXAMPLES:: - sage: g = sage.combinat.posets.poset_examples._random_distributive_lattice(10) # optional - sage.modules - sage: Poset(g).order_ideals_lattice(as_ideals=False).cardinality() # optional - sage.modules + sage: g = sage.combinat.posets.poset_examples._random_distributive_lattice(10) + sage: Poset(g).order_ideals_lattice(as_ideals=False).cardinality() 10 ALGORITHM: @@ -2095,8 +2096,8 @@ def _random_stone_lattice(n): EXAMPLES:: - sage: g = sage.combinat.posets.poset_examples._random_stone_lattice(10) # optional - sage.combinat - sage: LatticePoset(g).is_stone() # optional - sage.combinat + sage: g = sage.combinat.posets.poset_examples._random_stone_lattice(10) + sage: LatticePoset(g).is_stone() True ALGORITHM: diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py index c21bcc899e1..1173ca6548f 100644 --- a/src/sage/combinat/posets/posets.py +++ b/src/sage/combinat/posets/posets.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# sage.doctest: needs sage.graphs sage.modules r""" Finite posets @@ -433,7 +434,8 @@ def Poset(data=None, element_labels=None, cover_relations=False, linear_extensio With a function that identifies the cover relations: the set partitions of `\{1, 2, 3\}` ordered by refinement:: - sage: elms = SetPartitions(3) # optional - sage.combinat + sage: # needs sage.combinat + sage: elms = SetPartitions(3) sage: def fcn(A, B): ....: if len(A) != len(B)+1: ....: return False @@ -441,7 +443,7 @@ def Poset(data=None, element_labels=None, cover_relations=False, linear_extensio ....: if not any(set(a).issubset(b) for b in B): ....: return False ....: return True - sage: Poset((elms, fcn), cover_relations=True) # optional - sage.combinat + sage: Poset((elms, fcn), cover_relations=True) Finite poset containing 5 elements 3. A dictionary of upper covers:: @@ -1350,7 +1352,7 @@ def hasse_diagram(self): [1, 3, 5, 15] sage: H.edges(sort=True) [(1, 3, None), (1, 5, None), (3, 15, None), (5, 15, None)] - sage: H.set_latex_options(format="dot2tex") # optional - sage.plot + sage: H.set_latex_options(format="dot2tex") sage: view(H) # optional - dot2tex, not tested (opens external window) """ G = DiGraph(self._hasse_diagram).relabel(self._list, inplace=False) @@ -1396,8 +1398,8 @@ def _repr_(self): sage: P5._repr_() 'Finite poset containing 7 elements' - sage: M = MeetSemilattice([[1,2],[3],[3]]) # optional - sage.modules - sage: M._repr_() # optional - sage.modules + sage: M = MeetSemilattice([[1,2],[3],[3]]) + sage: M._repr_() 'Finite meet-semilattice containing 3 elements' """ s = "%s containing %s elements" % (self._desc, self._hasse_diagram.order()) @@ -1499,14 +1501,14 @@ def sorted(self, l, allow_incomparable=True, remove_duplicates=False): TESTS:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.sorted([], allow_incomparable=True, remove_duplicates=True) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.sorted([], allow_incomparable=True, remove_duplicates=True) [] - sage: P.sorted([], allow_incomparable=False, remove_duplicates=True) # optional - sage.modules + sage: P.sorted([], allow_incomparable=False, remove_duplicates=True) [] - sage: P.sorted([], allow_incomparable=True, remove_duplicates=False) # optional - sage.modules + sage: P.sorted([], allow_incomparable=True, remove_duplicates=False) [] - sage: P.sorted([], allow_incomparable=False, remove_duplicates=False) # optional - sage.modules + sage: P.sorted([], allow_incomparable=False, remove_duplicates=False) [] """ v = [self._element_to_vertex(x) for x in l] @@ -1616,7 +1618,7 @@ def linear_extensions(self, facade=False): [1, 2, 3, 4, 6, 12] sage: L.cardinality() 5 - sage: L.list() # optional - sage.modules sage.rings.finite_rings + sage: L.list() [[1, 2, 3, 4, 6, 12], [1, 2, 4, 3, 6, 12], [1, 3, 2, 4, 6, 12], @@ -1630,9 +1632,9 @@ def linear_extensions(self, facade=False): With ``facade=True``, the elements of ``L`` are plain lists instead:: - sage: L = P.linear_extensions(facade=True) # optional - sage.modules sage.rings.finite_rings - sage: l = L.an_element() # optional - sage.modules sage.rings.finite_rings - sage: type(l) # optional - sage.modules sage.rings.finite_rings + sage: L = P.linear_extensions(facade=True) + sage: l = L.an_element() + sage: type(l) .. WARNING:: @@ -1640,13 +1642,13 @@ def linear_extensions(self, facade=False): In Sage <= 4.8, this function used to return a plain list of lists. To recover the previous functionality, please use:: - sage: L = list(P.linear_extensions(facade=True)); L # optional - sage.modules sage.rings.finite_rings + sage: L = list(P.linear_extensions(facade=True)); L [[1, 2, 3, 4, 6, 12], [1, 2, 4, 3, 6, 12], [1, 3, 2, 4, 6, 12], [1, 3, 2, 6, 4, 12], [1, 2, 3, 6, 4, 12]] - sage: type(L[0]) # optional - sage.modules sage.rings.finite_rings + sage: type(L[0]) .. SEEALSO:: :meth:`linear_extension`, :meth:`is_linear_extension` @@ -1654,7 +1656,7 @@ def linear_extensions(self, facade=False): TESTS:: sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] }) - sage: list(D.linear_extensions()) # optional - sage.modules sage.rings.finite_rings + sage: list(D.linear_extensions()) [[0, 1, 2, 3, 4], [0, 2, 1, 3, 4], [0, 2, 1, 4, 3], [0, 2, 4, 1, 3], [0, 1, 2, 4, 3]] """ return self._lin_ext_type(self, facade=facade) @@ -1678,19 +1680,19 @@ def spectrum(self, a): EXAMPLES:: sage: P = posets.ChainPoset(5) - sage: P.spectrum(2) # optional - sage.modules sage.rings.finite_rings + sage: P.spectrum(2) [0, 0, 1, 0, 0] sage: P = posets.BooleanLattice(3) - sage: P.spectrum(5) # optional - sage.modules sage.rings.finite_rings + sage: P.spectrum(5) [0, 0, 0, 4, 12, 16, 16, 0] - sage: P = posets.YoungDiagramPoset(Partition([3,2,1])) # optional - sage.combinat - sage: P.spectrum((0,1)) # optional - sage.combinat sage.modules sage.rings.finite_rings + sage: P = posets.YoungDiagramPoset(Partition([3,2,1])) # needs sage.combinat + sage: P.spectrum((0,1)) # needs sage.combinat [0, 8, 6, 2, 0, 0] sage: P = posets.AntichainPoset(4) - sage: P.spectrum(3) # optional - sage.modules sage.rings.finite_rings + sage: P.spectrum(3) [6, 6, 6, 6] TESTS:: @@ -1826,7 +1828,7 @@ def is_linear_extension(self, l) -> bool: [1, 2, 4, 3, 6, 12], [1, 3, 2, 4, 6, 12], [1, 3, 2, 6, 4, 12]] - sage: list(P.linear_extensions()) # optional - sage.modules sage.rings.finite_rings + sage: list(P.linear_extensions()) [[1, 2, 3, 4, 6, 12], [1, 2, 4, 3, 6, 12], [1, 3, 2, 4, 6, 12], @@ -1853,10 +1855,10 @@ def is_linear_extension(self, l) -> bool: sage: P.is_linear_extension(['David', 'McNeil', 'La', 'Lamentable', 'Aventure', 'de', 'Simon', 'Wiesenthal']) False """ - index = {x: i for (i, x) in enumerate(l)} + index = {x: i for i, x in enumerate(l)} return (len(l) == self.cardinality() and all(x in index for x in self) and - all(index[i] < index[j] for (i, j) in self.cover_relations())) + all(index[i] < index[j] for i, j in self.cover_relations())) def list(self): """ @@ -1931,37 +1933,41 @@ def plot(self, label_elements=True, element_labels=None, This function can be used without any parameters:: + sage: # needs sage.plot sage: D12 = posets.DivisorLattice(12) - sage: D12.plot() # optional - sage.plot + sage: D12.plot() Graphics object consisting of 14 graphics primitives Just the abstract form of the poset; examples of relabeling:: - sage: D12.plot(label_elements=False) # optional - sage.plot + sage: # needs sage.plot + sage: D12.plot(label_elements=False) Graphics object consisting of 8 graphics primitives sage: d = {1: 0, 2: 'a', 3: 'b', 4: 'c', 6: 'd', 12: 1} - sage: D12.plot(element_labels=d) # optional - sage.plot + sage: D12.plot(element_labels=d) Graphics object consisting of 14 graphics primitives sage: d = {i: str(factor(i)) for i in D12} - sage: D12.plot(element_labels=d) # optional - sage.plot + sage: D12.plot(element_labels=d) Graphics object consisting of 14 graphics primitives Some settings for coverings:: + sage: # needs sage.plot sage: d = {(a, b): b/a for a, b in D12.cover_relations()} - sage: D12.plot(cover_labels=d, cover_color='gray', cover_style='dotted') # optional - sage.plot + sage: D12.plot(cover_labels=d, cover_color='gray', cover_style='dotted') Graphics object consisting of 21 graphics primitives To emphasize some elements and show some options:: - sage: L = LatticePoset({0: [1, 2, 3, 4], 1: [12], 2: [6, 7], # optional - sage.modules + sage: # needs sage.plot + sage: L = LatticePoset({0: [1, 2, 3, 4], 1: [12], 2: [6, 7], ....: 3: [5, 9], 4: [5, 6, 10, 11], 5: [13], ....: 6: [12], 7: [12, 8, 9], 8: [13], 9: [13], ....: 10: [12], 11: [12], 12: [13]}) - sage: F = L.frattini_sublattice() # optional - sage.modules - sage: F_internal = [c for c in F.cover_relations() # optional - sage.modules + sage: F = L.frattini_sublattice() + sage: F_internal = [c for c in F.cover_relations() ....: if c in L.cover_relations()] - sage: L.plot(figsize=12, border=True, element_shape='s', # optional - sage.modules sage.plot + sage: L.plot(figsize=12, border=True, element_shape='s', ....: element_size=400, element_color='white', ....: element_colors={'blue': F, 'green': L.double_irreducibles()}, ....: cover_color='lightgray', cover_colors={'black': F_internal}, @@ -1972,51 +1978,56 @@ def plot(self, label_elements=True, element_labels=None, We check that ``label_elements`` and ``element_labels`` are honored:: + sage: # needs sage.plot sage: def get_plot_labels(P): ....: return sorted(t.string for t in P ....: if isinstance(t, sage.plot.text.Text)) sage: P1 = Poset({ 0:[1,2], 1:[3], 2:[3,4] }) sage: P2 = Poset({ 0:[1,2], 1:[3], 2:[3,4] }, facade=True) - sage: get_plot_labels(P1.plot(label_elements=False)) # optional - sage.plot + sage: get_plot_labels(P1.plot(label_elements=False)) [] - sage: get_plot_labels(P1.plot(label_elements=True)) # optional - sage.plot + sage: get_plot_labels(P1.plot(label_elements=True)) ['0', '1', '2', '3', '4'] sage: element_labels = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e'} - sage: get_plot_labels(P1.plot(element_labels=element_labels)) # optional - sage.plot + sage: get_plot_labels(P1.plot(element_labels=element_labels)) ['a', 'b', 'c', 'd', 'e'] - sage: get_plot_labels(P2.plot(element_labels=element_labels)) # optional - sage.plot + sage: get_plot_labels(P2.plot(element_labels=element_labels)) ['a', 'b', 'c', 'd', 'e'] The following checks that :trac:`18936` has been fixed and labels still work:: + sage: # needs sage.plot sage: P = Poset({0: [1,2], 1:[3]}) sage: heights = {1 : [0], 2 : [1], 3 : [2,3]} - sage: P.plot(heights=heights) # optional - sage.plot + sage: P.plot(heights=heights) Graphics object consisting of 8 graphics primitives sage: elem_labels = {0 : 'a', 1 : 'b', 2 : 'c', 3 : 'd'} - sage: P.plot(element_labels=elem_labels, heights=heights) # optional - sage.plot + sage: P.plot(element_labels=elem_labels, heights=heights) Graphics object consisting of 8 graphics primitives The following checks that equal labels are allowed (:trac:`15206`):: + sage: # needs sage.plot sage: P = Poset({1: [2,3]}) sage: labs = {i: P.rank(i) for i in range(1, 4)}; labs {1: 0, 2: 1, 3: 1} - sage: P.plot(element_labels=labs) # optional - sage.plot + sage: P.plot(element_labels=labs) Graphics object consisting of 6 graphics primitives The following checks that non-hashable labels are allowed (:trac:`15206`):: + sage: # needs sage.plot sage: P = Poset({1: [2,3]}) sage: labs = {1: [2, 3], 2: [], 3: []}; labs {1: [2, 3], 2: [], 3: []} - sage: P.plot(element_labels=labs) # optional - sage.plot + sage: P.plot(element_labels=labs) Graphics object consisting of 6 graphics primitives Plot of the empty poset:: + sage: # needs sage.plot sage: P = Poset({}) - sage: P.plot() # optional - sage.plot + sage: P.plot() Graphics object consisting of 0 graphics primitives """ graph = self.hasse_diagram() @@ -2046,7 +2057,7 @@ def plot(self, label_elements=True, element_labels=None, if label_elements and element_labels is not None: from sage.misc.element_with_label import ElementWithLabel relabeling = {self(element): ElementWithLabel(self(element), label) - for (element, label) in element_labels.items()} + for element, label in element_labels.items()} graph = graph.relabel(relabeling, inplace=False) if heights is not None: for key in heights: @@ -2054,14 +2065,14 @@ def plot(self, label_elements=True, element_labels=None, if cover_labels is not None: if callable(cover_labels): - for (v, w) in graph.edges(sort=True, labels=False): + for v, w in graph.edges(sort=True, labels=False): graph.set_edge_label(v, w, cover_labels(v, w)) elif isinstance(cover_labels, dict): - for (v, w) in cover_labels: + for v, w in cover_labels: graph.set_edge_label(self(v), self(w), cover_labels[(v, w)]) else: - for (v, w, l) in cover_labels: + for v, w, l in cover_labels: graph.set_edge_label(self(v), self(w), l) cover_labels = True else: @@ -2102,18 +2113,19 @@ def show(self, label_elements=True, element_labels=None, EXAMPLES:: + sage: # needs sage.plot sage: D = Poset({ 0:[1,2], 1:[3], 2:[3,4] }) - sage: D.plot(label_elements=False) # optional - sage.plot + sage: D.plot(label_elements=False) Graphics object consisting of 6 graphics primitives - sage: D.show() # optional - sage.plot + sage: D.show() sage: elm_labs = {0:'a', 1:'b', 2:'c', 3:'d', 4:'e'} - sage: D.show(element_labels=elm_labs) # optional - sage.plot + sage: D.show(element_labels=elm_labs) One more example with cover labels:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.show(cover_labels=lambda a, b: a - b) # optional - sage.modules sage.plot - + sage: # needs sage.plot + sage: P = posets.PentagonPoset() + sage: P.show(cover_labels=lambda a, b: a - b) """ # We split the arguments into those meant for plot() and those meant for show() # @@ -2287,8 +2299,8 @@ def diamonds(self): sage: P.diamonds() ([(0, 1, 2, 3)], True) - sage: P = posets.YoungDiagramPoset(Partition([3, 2, 2])) # optional - sage.combinat - sage: P.diamonds() # optional - sage.combinat + sage: P = posets.YoungDiagramPoset(Partition([3, 2, 2])) # needs sage.combinat + sage: P.diamonds() # needs sage.combinat ([((0, 0), (0, 1), (1, 0), (1, 1)), ((1, 0), (1, 1), (2, 0), (2, 1))], False) """ diamonds, all_diamonds_completed = self._hasse_diagram.diamonds() @@ -2328,23 +2340,23 @@ def meet(self, x, y): EXAMPLES:: sage: D = Poset({1:[2,3], 2:[4], 3:[4]}) - sage: D.meet(2, 3) # optional - sage.modules + sage: D.meet(2, 3) 1 sage: P = Poset({'a':['b', 'c'], 'b':['e', 'f'], 'c':['f', 'g'], ....: 'd':['f', 'g']}) - sage: P.meet('a', 'b') # optional - sage.modules + sage: P.meet('a', 'b') 'a' - sage: P.meet('e', 'a') # optional - sage.modules + sage: P.meet('e', 'a') 'a' - sage: P.meet('c', 'b') # optional - sage.modules + sage: P.meet('c', 'b') 'a' - sage: P.meet('e', 'f') # optional - sage.modules + sage: P.meet('e', 'f') 'b' - sage: P.meet('e', 'g') # optional - sage.modules + sage: P.meet('e', 'g') 'a' - sage: P.meet('c', 'd') is None # optional - sage.modules + sage: P.meet('c', 'd') is None True - sage: P.meet('g', 'f') is None # optional - sage.modules + sage: P.meet('g', 'f') is None True """ i, j = map(self._element_to_vertex, (x, y)) @@ -2362,23 +2374,23 @@ def join(self, x, y): EXAMPLES:: sage: D = Poset({1:[2,3], 2:[4], 3:[4]}) - sage: D.join(2, 3) # optional - sage.modules + sage: D.join(2, 3) 4 sage: P = Poset({'e':['b'], 'f':['b', 'c', 'd'], 'g':['c', 'd'], ....: 'b':['a'], 'c':['a']}) - sage: P.join('a', 'b') # optional - sage.modules + sage: P.join('a', 'b') 'a' - sage: P.join('e', 'a') # optional - sage.modules + sage: P.join('e', 'a') 'a' - sage: P.join('c', 'b') # optional - sage.modules + sage: P.join('c', 'b') 'a' - sage: P.join('e', 'f') # optional - sage.modules + sage: P.join('e', 'f') 'b' - sage: P.join('e', 'g') # optional - sage.modules + sage: P.join('e', 'g') 'a' - sage: P.join('c', 'd') is None # optional - sage.modules + sage: P.join('c', 'd') is None True - sage: P.join('g', 'f') is None # optional - sage.modules + sage: P.join('g', 'f') is None True """ i, j = map(self._element_to_vertex, (x, y)) @@ -2416,8 +2428,8 @@ def is_d_complete(self) -> bool: sage: D.is_d_complete() False - sage: P = Posets.YoungDiagramPoset(Partition([3, 2, 2]), dual=True) # optional - sage.combinat - sage: P.is_d_complete() # optional - sage.combinat + sage: P = Posets.YoungDiagramPoset(Partition([3, 2, 2]), dual=True) # needs sage.combinat + sage: P.is_d_complete() # needs sage.combinat True """ min_diamond = {} # Maps max of double-tailed diamond to min of double-tailed diamond @@ -2535,8 +2547,8 @@ def intervals_poset(self): sage: P.intervals_poset() Finite poset containing 3 elements - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.intervals_poset() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.intervals_poset() Finite lattice containing 13 elements TESTS:: @@ -2563,7 +2575,7 @@ def intervals_poset(self): ints = [tuple(u) for u in self.relations()] covers = [] - for (a, b) in ints: + for a, b in ints: covers.extend([[(a, b), (a, bb)] for bb in self.upper_covers(b)]) if a != b: covers.extend([[(a, b), (aa, b)] for aa in self.upper_covers(a) @@ -2599,8 +2611,8 @@ def relations_iterator(self, strict=False): sage: next(it), next(it) ([1, 1], [1, 2]) - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: list(P.relations_iterator(strict=True)) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: list(P.relations_iterator(strict=True)) [[0, 1], [0, 2], [0, 4], [0, 3], [1, 4], [2, 3], [2, 4], [3, 4]] .. SEEALSO:: @@ -2635,8 +2647,8 @@ def relations_number(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.relations_number() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.relations_number() 13 sage: posets.TamariLattice(4).relations_number() @@ -2668,8 +2680,8 @@ def linear_intervals_count(self) -> List[int]: EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.linear_intervals_count() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.linear_intervals_count() [5, 5, 2] sage: P = posets.TamariLattice(4) sage: P.linear_intervals_count() @@ -2714,12 +2726,12 @@ def is_linear_interval(self, x, y) -> bool: EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.is_linear_interval(0, 4) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.is_linear_interval(0, 4) False - sage: P.is_linear_interval(0, 3) # optional - sage.modules + sage: P.is_linear_interval(0, 3) True - sage: P.is_linear_interval(1, 3) # optional - sage.modules + sage: P.is_linear_interval(1, 3) False """ a = self._element_to_vertex(x) @@ -2749,44 +2761,44 @@ def is_incomparable_chain_free(self, m, n=None) -> bool: EXAMPLES:: sage: B3 = posets.BooleanLattice(3) - sage: B3.is_incomparable_chain_free(1, 3) # optional - sage.modules + sage: B3.is_incomparable_chain_free(1, 3) True - sage: B3.is_incomparable_chain_free(2, 2) # optional - sage.modules + sage: B3.is_incomparable_chain_free(2, 2) False - sage: IP6 = posets.IntegerPartitions(6) # optional - sage.combinat - sage: IP6.is_incomparable_chain_free(1, 3) # optional - sage.combinat sage.modules + sage: IP6 = posets.IntegerPartitions(6) # needs sage.combinat + sage: IP6.is_incomparable_chain_free(1, 3) # needs sage.combinat False - sage: IP6.is_incomparable_chain_free(2, 2) # optional - sage.combinat sage.modules + sage: IP6.is_incomparable_chain_free(2, 2) # needs sage.combinat True A list of pairs as an argument:: - sage: B3.is_incomparable_chain_free([[1, 3], [2, 2]]) # optional - sage.modules + sage: B3.is_incomparable_chain_free([[1, 3], [2, 2]]) False We show how to get an incomparable chain pair:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: chains_1_2 = Poset({0:[], 1:[2]}) # optional - sage.modules - sage: incomps = P.isomorphic_subposets(chains_1_2)[0] # optional - sage.modules - sage: sorted(incomps.list()), incomps.cover_relations() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: chains_1_2 = Poset({0:[], 1:[2]}) + sage: incomps = P.isomorphic_subposets(chains_1_2)[0] + sage: sorted(incomps.list()), incomps.cover_relations() ([1, 2, 3], [[2, 3]]) TESTS:: - sage: Poset().is_incomparable_chain_free(1,1) # Test empty poset # optional - sage.modules + sage: Poset().is_incomparable_chain_free(1,1) # Test empty poset True - sage: [len([p for p in Posets(n) # long time # optional - sage.modules + sage: [len([p for p in Posets(n) # long time ....: if p.is_incomparable_chain_free(((3, 1), (2, 2)))]) ....: for n in range(6)] [1, 1, 2, 5, 14, 42] sage: Q = Poset({0:[2], 1:[2], 2:[3], 3:[4], 4:[]}) - sage: Q.is_incomparable_chain_free(2, 20/10) # optional - sage.modules + sage: Q.is_incomparable_chain_free(2, 20/10) True - sage: Q.is_incomparable_chain_free(2, pi) # optional - sage.symbolic + sage: Q.is_incomparable_chain_free(2, pi) # needs sage.symbolic Traceback (most recent call last): ... TypeError: 2 and pi must be integers @@ -2803,9 +2815,9 @@ def is_incomparable_chain_free(self, m, n=None) -> bool: Traceback (most recent call last): ... TypeError: [3, 1] and [2, 2] must be integers - sage: P.is_incomparable_chain_free([[3, 1], [2, 2]]) # optional - sage.modules + sage: P.is_incomparable_chain_free([[3, 1], [2, 2]]) True - sage: P.is_incomparable_chain_free(([3, 1], [2, 2])) # optional - sage.modules + sage: P.is_incomparable_chain_free(([3, 1], [2, 2])) True sage: P.is_incomparable_chain_free([3, 1], 2) Traceback (most recent call last): @@ -3140,7 +3152,7 @@ def height(self, certificate=False): sage: P = Poset({0: [1], 2: [3, 4], 4: [5, 6]}) sage: P.height() 3 - sage: posets.PentagonPoset().height(certificate=True) # optional - sage.modules + sage: posets.PentagonPoset().height(certificate=True) (4, [0, 2, 3, 4]) TESTS:: @@ -3186,14 +3198,14 @@ def has_isomorphic_subposet(self, other): sage: D = Poset({1:[2,3], 2:[4], 3:[4]}) sage: T = Poset({1:[2,3], 2:[4,5], 3:[6,7]}) - sage: N5 = posets.PentagonPoset() # optional - sage.modules + sage: N5 = posets.PentagonPoset() - sage: N5.has_isomorphic_subposet(T) # optional - sage.modules + sage: N5.has_isomorphic_subposet(T) False - sage: N5.has_isomorphic_subposet(D) # optional - sage.modules + sage: N5.has_isomorphic_subposet(D) True - sage: len([P for P in Posets(5) if P.has_isomorphic_subposet(D)]) # optional - sage.modules + sage: len([P for P in Posets(5) if P.has_isomorphic_subposet(D)]) 11 """ @@ -3341,17 +3353,17 @@ def is_antichain_of_poset(self, elms): TESTS:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.is_antichain_of_poset([]) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.is_antichain_of_poset([]) True - sage: P.is_antichain_of_poset([0]) # optional - sage.modules + sage: P.is_antichain_of_poset([0]) True - sage: P.is_antichain_of_poset([1, 2, 1]) # optional - sage.modules + sage: P.is_antichain_of_poset([1, 2, 1]) True Check :trac:`19078`:: - sage: P.is_antichain_of_poset([0, 1, 'junk']) # optional - sage.modules + sage: P.is_antichain_of_poset([0, 1, 'junk']) Traceback (most recent call last): ... ValueError: element (=junk) not in poset @@ -3704,37 +3716,39 @@ def magnitude(self) -> Integer: EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.magnitude() # optional - sage.libs.flint sage.modules + sage: # needs sage.groups sage.libs.flint + sage: P = posets.PentagonPoset() + sage: P.magnitude() 1 - sage: W = SymmetricGroup(4) # optional - sage.groups - sage: P = W.noncrossing_partition_lattice().without_bounds() # optional - sage.groups - sage: P.magnitude() # optional - sage.groups sage.libs.flint sage.modules + sage: W = SymmetricGroup(4) + sage: P = W.noncrossing_partition_lattice().without_bounds() + sage: P.magnitude() -4 sage: P = posets.TamariLattice(4).without_bounds() - sage: P.magnitude() # optional - sage.libs.flint sage.modules + sage: P.magnitude() 0 .. SEEALSO:: :meth:`order_complex` TESTS:: + sage: # needs sage.groups sage.libs.flint sage: P1 = posets.RandomPoset(20, 0.05) sage: P2 = posets.RandomPoset(20, 0.05) - sage: m1 = P1.magnitude() # optional - sage.libs.flint sage.modules - sage: m2 = P2.magnitude() # optional - sage.libs.flint sage.modules + sage: m1 = P1.magnitude() + sage: m2 = P2.magnitude() sage: U = P1.disjoint_union(P2) sage: P = P1.product(P2) - sage: U.magnitude() == m1 + m2 # optional - sage.libs.flint sage.modules + sage: U.magnitude() == m1 + m2 True - sage: P.magnitude() == m1*m2 # optional - sage.libs.flint sage.modules + sage: P.magnitude() == m1*m2 True - sage: Poset({}).magnitude() # optional - sage.libs.flint sage.modules + sage: Poset({}).magnitude() 0 - sage: Poset({1:[]}).magnitude() # optional - sage.libs.flint sage.modules + sage: Poset({1:[]}).magnitude() 1 """ H = self._hasse_diagram @@ -3865,10 +3879,10 @@ def is_jump_critical(self, certificate=False): sage: P.is_jump_critical() True - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.is_jump_critical() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.is_jump_critical() False - sage: P.is_jump_critical(certificate=True) # optional - sage.modules + sage: P.is_jump_critical(certificate=True) (False, 3) .. SEEALSO:: :meth:`jump_number` @@ -4027,8 +4041,8 @@ def is_graded(self) -> bool: EXAMPLES:: - sage: P = posets.PentagonPoset() # Not even ranked # optional - sage.modules - sage: P.is_graded() # optional - sage.modules + sage: P = posets.PentagonPoset() # Not even ranked + sage: P.is_graded() False sage: P = Poset({1:[2, 3], 3:[4]}) # Ranked, but not graded @@ -4217,20 +4231,20 @@ def moebius_function_matrix(self, ring=ZZ, sparse=False): sage: x,y = (P.linear_extension()[0],P.linear_extension()[1]) sage: P.moebius_function(x,y) -1 - sage: M = P.moebius_function_matrix(); M # optional - sage.libs.flint sage.modules + sage: M = P.moebius_function_matrix(); M # needs sage.libs.flint [ 1 -1 -1 -1 2] [ 0 1 0 0 -1] [ 0 0 1 0 -1] [ 0 0 0 1 -1] [ 0 0 0 0 1] - sage: M[0,4] # optional - sage.libs.flint sage.modules + sage: M[0,4] # needs sage.libs.flint 2 - sage: M[0,1] # optional - sage.libs.flint sage.modules + sage: M[0,1] # needs sage.libs.flint -1 We now demonstrate the usage of the optional parameters:: - sage: P.moebius_function_matrix(ring=QQ, sparse=False).parent() # optional - sage.libs.flint sage.modules + sage: P.moebius_function_matrix(ring=QQ, sparse=False).parent() # needs sage.libs.flint Full MatrixSpace of 5 by 5 dense matrices over Rational Field """ M = self._hasse_diagram.moebius_function_matrix() @@ -4255,7 +4269,7 @@ def lequal_matrix(self, ring=ZZ, sparse=False): EXAMPLES:: sage: P = Poset([[1,3,2],[4],[4,5,6],[6],[7],[7],[7],[]], facade=False) - sage: LEQM = P.lequal_matrix(); LEQM # optional - sage.modules + sage: LEQM = P.lequal_matrix(); LEQM [1 1 1 1 1 1 1 1] [0 1 0 1 0 0 0 1] [0 0 1 1 1 0 1 1] @@ -4264,18 +4278,18 @@ def lequal_matrix(self, ring=ZZ, sparse=False): [0 0 0 0 0 1 1 1] [0 0 0 0 0 0 1 1] [0 0 0 0 0 0 0 1] - sage: LEQM[1,3] # optional - sage.modules + sage: LEQM[1,3] 1 sage: P.linear_extension()[1] < P.linear_extension()[3] True - sage: LEQM[2,5] # optional - sage.modules + sage: LEQM[2,5] 0 sage: P.linear_extension()[2] < P.linear_extension()[5] False We now demonstrate the usage of the optional parameters:: - sage: P.lequal_matrix(ring=QQ, sparse=False).parent() # optional - sage.libs.flint sage.modules + sage: P.lequal_matrix(ring=QQ, sparse=False).parent() # needs sage.libs.flint Full MatrixSpace of 8 by 8 dense matrices over Rational Field """ M = self._hasse_diagram.lequal_matrix(boolean=False) @@ -4301,7 +4315,7 @@ def coxeter_transformation(self): EXAMPLES:: - sage: posets.PentagonPoset().coxeter_transformation() # optional - sage.modules + sage: posets.PentagonPoset().coxeter_transformation() [ 0 0 0 0 -1] [ 0 0 0 1 -1] [ 0 1 0 0 -1] @@ -4314,8 +4328,8 @@ def coxeter_transformation(self): TESTS:: - sage: M = posets.PentagonPoset().coxeter_transformation() # optional - sage.modules - sage: M ** 8 == 1 # optional - sage.modules + sage: M = posets.PentagonPoset().coxeter_transformation() + sage: M ** 8 == 1 True """ return self._hasse_diagram.coxeter_transformation() @@ -4334,12 +4348,12 @@ def coxeter_polynomial(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.coxeter_polynomial() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.coxeter_polynomial() x^5 + x^4 + x + 1 - sage: p = posets.SymmetricGroupWeakOrderPoset(3) # optional - sage.groups - sage: p.coxeter_polynomial() # optional - sage.groups sage.modules + sage: p = posets.SymmetricGroupWeakOrderPoset(3) # needs sage.groups + sage: p.coxeter_polynomial() # needs sage.groups x^6 + x^5 - x^3 + x + 1 .. SEEALSO:: @@ -4374,28 +4388,28 @@ def coxeter_smith_form(self, algorithm='singular'): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.coxeter_smith_form() # optional - sage.modules sage.libs.singular + sage: P = posets.PentagonPoset() + sage: P.coxeter_smith_form() # needs sage.libs.singular [1, 1, 1, 1, x^5 + x^4 + x + 1] sage: P = posets.DiamondPoset(7) - sage: prod(P.coxeter_smith_form()) == P.coxeter_polynomial() # optional - sage.modules sage.libs.singular + sage: prod(P.coxeter_smith_form()) == P.coxeter_polynomial() # needs sage.libs.singular True TESTS:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.coxeter_smith_form(algorithm='sage') # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.coxeter_smith_form(algorithm='sage') [1, 1, 1, 1, x^5 + x^4 + x + 1] - sage: P.coxeter_smith_form(algorithm='gap') # optional - sage.libs.gap sage.modules + sage: P.coxeter_smith_form(algorithm='gap') # needs sage.libs.gap [1, 1, 1, 1, x^5 + x^4 + x + 1] - sage: P.coxeter_smith_form(algorithm='pari') # optional - sage.libs.pari sage.modules + sage: P.coxeter_smith_form(algorithm='pari') # needs sage.libs.pari [1, 1, 1, 1, x^5 + x^4 + x + 1] - sage: P.coxeter_smith_form(algorithm='fricas') # optional - fricas # optional - sage.modules + sage: P.coxeter_smith_form(algorithm='fricas') # optional - fricas [1, 1, 1, 1, x^5 + x^4 + x + 1] - sage: P.coxeter_smith_form(algorithm='maple') # optional - maple # optional - sage.modules + sage: P.coxeter_smith_form(algorithm='maple') # optional - maple [1, 1, 1, 1, x^5 + x^4 + x + 1] - sage: P.coxeter_smith_form(algorithm='magma') # optional - magma # optional - sage.modules + sage: P.coxeter_smith_form(algorithm='magma') # optional - magma [1, 1, 1, 1, x^5 + x^4 + x + 1] .. SEEALSO:: @@ -4471,15 +4485,15 @@ def is_meet_semilattice(self, certificate=False): EXAMPLES:: sage: P = Poset({1:[2, 3, 4], 2:[5, 6], 3:[6], 4:[6, 7]}) - sage: P.is_meet_semilattice() # optional - sage.modules + sage: P.is_meet_semilattice() True sage: Q = P.dual() - sage: Q.is_meet_semilattice() # optional - sage.modules + sage: Q.is_meet_semilattice() False - sage: V = posets.IntegerPartitions(5) # optional - sage.combinat - sage: V.is_meet_semilattice(certificate=True) # optional - sage.combinat sage.modules + sage: V = posets.IntegerPartitions(5) # needs sage.combinat + sage: V.is_meet_semilattice(certificate=True) # needs sage.combinat (False, ((2, 2, 1), (3, 1, 1))) .. SEEALSO:: @@ -4489,13 +4503,13 @@ def is_meet_semilattice(self, certificate=False): TESTS:: - sage: Poset().is_meet_semilattice() # Test empty lattice # optional - sage.modules + sage: Poset().is_meet_semilattice() # Test empty lattice True - sage: len([P for P in Posets(4) if P.is_meet_semilattice()]) # optional - sage.modules + sage: len([P for P in Posets(4) if P.is_meet_semilattice()]) 5 sage: P = Poset({1: [2], 3: []}) - sage: P.is_meet_semilattice(certificate=True) # optional - sage.modules + sage: P.is_meet_semilattice(certificate=True) (False, (3, 1)) """ from sage.combinat.posets.hasse_diagram import LatticeError @@ -4544,13 +4558,13 @@ def is_join_semilattice(self, certificate=False): EXAMPLES:: sage: P = Poset([[1,3,2], [4], [4,5,6], [6], [7], [7], [7], []]) - sage: P.is_join_semilattice() # optional - sage.modules + sage: P.is_join_semilattice() True sage: P = Poset({1:[3, 4], 2:[3, 4], 3:[5], 4:[5]}) - sage: P.is_join_semilattice() # optional - sage.modules + sage: P.is_join_semilattice() False - sage: P.is_join_semilattice(certificate=True) # optional - sage.modules + sage: P.is_join_semilattice(certificate=True) (False, (2, 1)) .. SEEALSO:: @@ -4560,13 +4574,13 @@ def is_join_semilattice(self, certificate=False): TESTS:: - sage: Poset().is_join_semilattice() # Test empty lattice # optional - sage.modules + sage: Poset().is_join_semilattice() # Test empty lattice True - sage: len([P for P in Posets(4) if P.is_join_semilattice()]) # optional - sage.modules + sage: len([P for P in Posets(4) if P.is_join_semilattice()]) 5 sage: X = Poset({1: [3], 2: [3], 3: [4, 5]}) - sage: X.is_join_semilattice(certificate=True) # optional - sage.modules + sage: X.is_join_semilattice(certificate=True) (False, (5, 4)) """ from sage.combinat.posets.hasse_diagram import LatticeError @@ -4634,8 +4648,8 @@ def isomorphic_subposets_iterator(self, other): EXAMPLES:: sage: D = Poset({1:[2,3], 2:[4], 3:[4]}) - sage: N5 = posets.PentagonPoset() # optional - sage.modules - sage: for P in N5.isomorphic_subposets_iterator(D): # optional - sage.modules + sage: N5 = posets.PentagonPoset() + sage: for P in N5.isomorphic_subposets_iterator(D): ....: print(P.cover_relations()) [[0, 1], [0, 2], [1, 4], [2, 4]] [[0, 1], [0, 3], [1, 4], [3, 4]] @@ -4674,15 +4688,15 @@ def isomorphic_subposets(self, other): sage: C2 = Poset({0:[1]}) sage: C3 = Poset({'a':['b'], 'b':['c']}) - sage: L = sorted(x.cover_relations() for x in C3.isomorphic_subposets(C2)) # optional - sage.modules - sage: for x in L: print(x) # optional - sage.modules + sage: L = sorted(x.cover_relations() for x in C3.isomorphic_subposets(C2)) + sage: for x in L: print(x) [['a', 'b']] [['a', 'c']] [['b', 'c']] sage: D = Poset({1:[2,3], 2:[4], 3:[4]}) - sage: N5 = posets.PentagonPoset() # optional - sage.modules - sage: len(N5.isomorphic_subposets(D)) # optional - sage.modules + sage: N5 = posets.PentagonPoset() + sage: len(N5.isomorphic_subposets(D)) 2 .. NOTE:: @@ -4719,19 +4733,19 @@ def antichains(self, element_constructor=type([])): EXAMPLES:: - sage: A = posets.PentagonPoset().antichains(); A # optional - sage.modules + sage: A = posets.PentagonPoset().antichains(); A Set of antichains of Finite lattice containing 5 elements - sage: list(A) # optional - sage.modules + sage: list(A) [[], [0], [1], [1, 2], [1, 3], [2], [3], [4]] - sage: A.cardinality() # optional - sage.modules + sage: A.cardinality() 8 - sage: A[3] # optional - sage.modules + sage: A[3] [1, 2] To get the antichains as, say, sets, one may use the ``element_constructor`` option:: - sage: list(posets.ChainPoset(3).antichains(element_constructor=set)) # optional - sage.modules + sage: list(posets.ChainPoset(3).antichains(element_constructor=set)) [set(), {0}, {1}, {2}] To get the antichains of a given size one can currently use:: @@ -4774,9 +4788,9 @@ def antichains_iterator(self): EXAMPLES:: - sage: it = posets.PentagonPoset().antichains_iterator(); it # optional - sage.modules + sage: it = posets.PentagonPoset().antichains_iterator(); it - sage: next(it), next(it) # optional - sage.modules + sage: next(it), next(it) ([], [4]) .. SEEALSO:: :meth:`antichains` @@ -4928,9 +4942,9 @@ def chains(self, element_constructor=type([]), exclude=None): EXAMPLES:: - sage: C = posets.PentagonPoset().chains(); C # optional - sage.modules + sage: C = posets.PentagonPoset().chains(); C Set of chains of Finite lattice containing 5 elements - sage: list(C) # optional - sage.modules + sage: list(C) [[], [0], [0, 1], [0, 1, 4], [0, 2], [0, 2, 3], [0, 2, 3, 4], [0, 2, 4], [0, 3], [0, 3, 4], [0, 4], [1], [1, 4], [2], [2, 3], [2, 3, 4], [2, 4], [3], [3, 4], [4]] @@ -4943,12 +4957,12 @@ def chains(self, element_constructor=type([]), exclude=None): To get the chains of a given size one can currently use:: - sage: list(C.elements_of_depth_iterator(2)) # optional - sage.modules + sage: list(C.elements_of_depth_iterator(2)) [[0, 1], [0, 2], [0, 3], [0, 4], [1, 4], [2, 3], [2, 4], [3, 4]] Eventually the following syntax will be accepted:: - sage: C.subset(size = 2) # todo: not implemented # optional - sage.modules + sage: C.subset(size = 2) # not implemented .. SEEALSO:: :meth:`maximal_chains`, :meth:`antichains` """ @@ -5112,23 +5126,23 @@ def product(self, other): sage: P = posets.ChainPoset(3) sage: Q = posets.ChainPoset(4) - sage: PQ = P.product(Q) ; PQ # optional - sage.modules + sage: PQ = P.product(Q) ; PQ Finite lattice containing 12 elements - sage: len(PQ.cover_relations()) # optional - sage.modules + sage: len(PQ.cover_relations()) 17 - sage: Q.product(P).is_isomorphic(PQ) # optional - sage.modules + sage: Q.product(P).is_isomorphic(PQ) True sage: P = posets.BooleanLattice(2) - sage: Q = P.product(P) # optional - sage.modules - sage: Q.is_isomorphic(posets.BooleanLattice(4)) # optional - sage.modules + sage: Q = P.product(P) + sage: Q.is_isomorphic(posets.BooleanLattice(4)) True One can also simply use `*`:: sage: P = posets.ChainPoset(2) sage: Q = posets.ChainPoset(3) - sage: P*Q # optional - sage.modules + sage: P*Q Finite lattice containing 6 elements .. SEEALSO:: @@ -5137,15 +5151,15 @@ def product(self, other): TESTS:: - sage: Poset({0: [1]}).product(Poset()) # Product with empty poset # optional - sage.modules + sage: Poset({0: [1]}).product(Poset()) # Product with empty poset Finite poset containing 0 elements - sage: Poset().product(Poset()) # Product of two empty poset # optional - sage.modules + sage: Poset().product(Poset()) # Product of two empty poset Finite poset containing 0 elements We check that :trac:`19113` is fixed:: - sage: L = LatticePoset({1: []}) # optional - sage.modules - sage: type(L) == type(L.product(L)) # optional - sage.modules + sage: L = LatticePoset({1: []}) + sage: type(L) == type(L.product(L)) True """ from sage.combinat.posets.lattices import LatticePoset, \ @@ -5235,9 +5249,9 @@ def factor(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: Q = P*P # optional - sage.modules - sage: Q.factor() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: Q = P*P + sage: Q.factor() [Finite poset containing 5 elements, Finite poset containing 5 elements] @@ -5245,12 +5259,12 @@ def factor(self): sage: P2 = posets.ChainPoset(7) sage: P1.factor() [Finite lattice containing 3 elements] - sage: (P1 * P2).factor() # optional - sage.modules + sage: (P1 * P2).factor() [Finite poset containing 7 elements, Finite poset containing 3 elements] sage: P = posets.TamariLattice(4) - sage: (P*P).factor() # optional - sage.modules + sage: (P*P).factor() [Finite poset containing 14 elements, Finite poset containing 14 elements] @@ -5372,9 +5386,9 @@ def disjoint_union(self, other, labels='pairs'): sage: P.cover_relations() [[2, 3], [0, 1]] - sage: N5 = posets.PentagonPoset(); N5 # optional - sage.modules + sage: N5 = posets.PentagonPoset(); N5 Finite lattice containing 5 elements - sage: N5.disjoint_union(N5) # Union of lattices is not a lattice # optional - sage.modules + sage: N5.disjoint_union(N5) # Union of lattices is not a lattice Finite poset containing 10 elements We show how to get literally direct sum with elements untouched:: @@ -5387,9 +5401,9 @@ def disjoint_union(self, other, labels='pairs'): TESTS:: - sage: N5 = posets.PentagonPoset() # optional - sage.modules + sage: N5 = posets.PentagonPoset() sage: P0 = Poset() - sage: N5.disjoint_union(P0).is_isomorphic(N5) # optional - sage.modules + sage: N5.disjoint_union(P0).is_isomorphic(N5) True sage: P0.disjoint_union(P0) Finite poset containing 0 elements @@ -5451,11 +5465,11 @@ def ordinal_product(self, other, labels='pairs'): ... ValueError: labels must be either 'pairs' or 'integers' - sage: N5 = posets.PentagonPoset() # optional - sage.modules + sage: N5 = posets.PentagonPoset() sage: P0 = Poset() - sage: N5.ordinal_product(P0) == P0 # optional - sage.modules + sage: N5.ordinal_product(P0) == P0 True - sage: P0.ordinal_product(N5) == P0 # optional - sage.modules + sage: P0.ordinal_product(N5) == P0 True sage: P0.ordinal_product(P0) == P0 True @@ -5469,7 +5483,7 @@ def ordinal_product(self, other, labels='pairs'): sage: C3 = posets.ChainPoset(3) sage: C4 = posets.ChainPoset(4) sage: C12 = posets.ChainPoset(12) - sage: C3.ordinal_product(C4).is_isomorphic(C12) # optional - sage.modules + sage: C3.ordinal_product(C4).is_isomorphic(C12) True """ from sage.combinat.posets.lattices import LatticePoset, \ @@ -5546,15 +5560,15 @@ def ordinal_sum(self, other, labels='pairs'): sage: P = Poset({1:[2]}); P Finite poset containing 2 elements - sage: JL = JoinSemilattice({1:[2]}); JL # optional - sage.modules + sage: JL = JoinSemilattice({1:[2]}); JL Finite join-semilattice containing 2 elements - sage: L = LatticePoset({1:[2]}); L # optional - sage.modules + sage: L = LatticePoset({1:[2]}); L Finite lattice containing 2 elements - sage: P.ordinal_sum(L) # optional - sage.modules + sage: P.ordinal_sum(L) Finite poset containing 4 elements - sage: L.ordinal_sum(JL) # optional - sage.modules + sage: L.ordinal_sum(JL) Finite join-semilattice containing 4 elements - sage: L.ordinal_sum(L) # optional - sage.modules + sage: L.ordinal_sum(L) Finite lattice containing 4 elements .. SEEALSO:: @@ -5564,11 +5578,11 @@ def ordinal_sum(self, other, labels='pairs'): TESTS:: - sage: N5 = posets.PentagonPoset() # optional - sage.modules + sage: N5 = posets.PentagonPoset() sage: P0 = LatticePoset({}) - sage: N5.ordinal_sum(P0).is_isomorphic(N5) # optional - sage.modules + sage: N5.ordinal_sum(P0).is_isomorphic(N5) True - sage: P0.ordinal_sum(P0) # optional - sage.modules + sage: P0.ordinal_sum(P0) Finite lattice containing 0 elements """ from sage.combinat.posets.lattices import LatticePoset, \ @@ -5635,7 +5649,7 @@ def star_product(self, other, labels='pairs'): sage: B3 = posets.BooleanLattice(3) sage: P = B2.star_product(B3); P Finite poset containing 10 elements - sage: P.is_eulerian() # optional - sage.libs.flint sage.modules + sage: P.is_eulerian() # needs sage.libs.flint True We can get elements as pairs or as integers:: @@ -5726,11 +5740,11 @@ def lexicographic_sum(self, P): EXAMPLES:: sage: N = Poset({1: [3, 4], 2: [4]}) - sage: P = {1: posets.PentagonPoset(), 2: N, # optional - sage.modules + sage: P = {1: posets.PentagonPoset(), 2: N, ....: 3: posets.ChainPoset(3), 4: posets.AntichainPoset(4)} - sage: NP = N.lexicographic_sum(P); NP # optional - sage.modules + sage: NP = N.lexicographic_sum(P); NP Finite poset containing 16 elements - sage: sorted(NP.minimal_elements()) # optional - sage.modules + sage: sorted(NP.minimal_elements()) [(1, 0), (2, 1), (2, 2)] TESTS:: @@ -5813,10 +5827,10 @@ def dual(self): join-semilattice and vice versa. Also the dual of a (non-)facade poset is again (non-)facade:: - sage: V = MeetSemilattice({1: [2, 3]}, facade=False) # optional - sage.modules - sage: A = V.dual(); A # optional - sage.modules + sage: V = MeetSemilattice({1: [2, 3]}, facade=False) + sage: A = V.dual(); A Finite join-semilattice containing 3 elements - sage: A(2) < A(1) # optional - sage.modules + sage: A(2) < A(1) True .. SEEALSO:: :meth:`~sage.categories.finite_posets.FinitePosets.ParentMethods.is_self_dual` @@ -5869,12 +5883,12 @@ def with_bounds(self, labels=('bottom', 'top')): sage: Y.cover_relations() [[-1, 0], [0, 1], [0, 2]] - sage: P = posets.PentagonPoset() # A lattice # optional - sage.modules - sage: P.with_bounds() # optional - sage.modules + sage: P = posets.PentagonPoset() # A lattice + sage: P.with_bounds() Finite lattice containing 7 elements - sage: P = posets.PentagonPoset(facade=False) # optional - sage.modules - sage: P.with_bounds() # optional - sage.modules + sage: P = posets.PentagonPoset(facade=False) + sage: P.with_bounds() Finite lattice containing 7 elements .. SEEALSO:: @@ -5887,58 +5901,58 @@ def with_bounds(self, labels=('bottom', 'top')): sage: P.cover_relations() [['bottom', 'top']] - sage: L = LatticePoset({}).with_bounds(); L # optional - sage.modules + sage: L = LatticePoset({}).with_bounds(); L Finite lattice containing 2 elements - sage: L.meet_irreducibles() # Issue 21543 # optional - sage.modules + sage: L.meet_irreducibles() # Issue 21543 ['bottom'] sage: Poset().with_bounds((None, 1)) Finite poset containing 1 elements - sage: LatticePoset().with_bounds((None, 1)) # optional - sage.modules + sage: LatticePoset().with_bounds((None, 1)) Finite lattice containing 1 elements - sage: MeetSemilattice().with_bounds((None, 1)) # optional - sage.modules + sage: MeetSemilattice().with_bounds((None, 1)) Finite lattice containing 1 elements - sage: JoinSemilattice().with_bounds((None, 1)) # optional - sage.modules + sage: JoinSemilattice().with_bounds((None, 1)) Finite join-semilattice containing 1 elements sage: Poset().with_bounds((1, None)) Finite poset containing 1 elements - sage: LatticePoset().with_bounds((1, None)) # optional - sage.modules + sage: LatticePoset().with_bounds((1, None)) Finite lattice containing 1 elements - sage: MeetSemilattice().with_bounds((1, None)) # optional - sage.modules + sage: MeetSemilattice().with_bounds((1, None)) Finite meet-semilattice containing 1 elements - sage: JoinSemilattice().with_bounds((1, None)) # optional - sage.modules + sage: JoinSemilattice().with_bounds((1, None)) Finite lattice containing 1 elements sage: P = Poset({0: []}) - sage: L = LatticePoset({0: []}) # optional - sage.modules - sage: ML = MeetSemilattice({0: []}) # optional - sage.modules - sage: JL = JoinSemilattice({0: []}) # optional - sage.modules + sage: L = LatticePoset({0: []}) + sage: ML = MeetSemilattice({0: []}) + sage: JL = JoinSemilattice({0: []}) sage: P.with_bounds((None, None)) Finite poset containing 1 elements - sage: L.with_bounds((None, None)) # optional - sage.modules + sage: L.with_bounds((None, None)) Finite lattice containing 1 elements - sage: ML.with_bounds((None, None)) # optional - sage.modules + sage: ML.with_bounds((None, None)) Finite meet-semilattice containing 1 elements - sage: JL.with_bounds((None, None)) # optional - sage.modules + sage: JL.with_bounds((None, None)) Finite join-semilattice containing 1 elements sage: P.with_bounds((1, None)) Finite poset containing 2 elements - sage: L.with_bounds((1, None)) # optional - sage.modules + sage: L.with_bounds((1, None)) Finite lattice containing 2 elements - sage: ML.with_bounds((1, None)) # optional - sage.modules + sage: ML.with_bounds((1, None)) Finite meet-semilattice containing 2 elements - sage: JL.with_bounds((1, None)) # optional - sage.modules + sage: JL.with_bounds((1, None)) Finite lattice containing 2 elements sage: P.with_bounds((None, 1)) Finite poset containing 2 elements - sage: L.with_bounds((None, 1)) # optional - sage.modules + sage: L.with_bounds((None, 1)) Finite lattice containing 2 elements - sage: ML.with_bounds((None, 1)) # optional - sage.modules + sage: ML.with_bounds((None, 1)) Finite lattice containing 2 elements - sage: JL.with_bounds((None, 1)) # optional - sage.modules + sage: JL.with_bounds((None, 1)) Finite join-semilattice containing 2 elements - sage: posets.PentagonPoset().with_bounds(labels=(4, 5)) # optional - sage.modules + sage: posets.PentagonPoset().with_bounds(labels=(4, 5)) Traceback (most recent call last): ... ValueError: the poset already has element 4 @@ -5997,10 +6011,10 @@ def without_bounds(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: Q = P.without_bounds(); Q # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: Q = P.without_bounds(); Q Finite poset containing 3 elements - sage: Q.cover_relations() # optional - sage.modules + sage: Q.cover_relations() [[2, 3]] sage: P = posets.DiamondPoset(5) @@ -6092,27 +6106,27 @@ def relabel(self, relabeling=None): Relabeling using a list:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: list(P) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: list(P) [0, 1, 2, 3, 4] - sage: P.cover_relations() # optional - sage.modules + sage: P.cover_relations() [[0, 1], [0, 2], [1, 4], [2, 3], [3, 4]] - sage: Q = P.relabel(list('abcde')) # optional - sage.modules - sage: Q.cover_relations() # optional - sage.modules + sage: Q = P.relabel(list('abcde')) + sage: Q.cover_relations() [['a', 'b'], ['a', 'c'], ['b', 'e'], ['c', 'd'], ['d', 'e']] Default behaviour is increasing relabeling:: sage: a2 = posets.ChainPoset(2) - sage: P = a2 * a2 # optional - sage.modules - sage: Q = P.relabel() # optional - sage.modules - sage: Q.cover_relations() # optional - sage.modules + sage: P = a2 * a2 + sage: Q = P.relabel() + sage: Q.cover_relations() [[0, 1], [0, 2], [1, 3], [2, 3]] Relabeling a (semi)lattice gives a (semi)lattice:: - sage: P = JoinSemilattice({0: [1]}) # optional - sage.modules - sage: P.relabel(lambda n: n+1) # optional - sage.modules + sage: P = JoinSemilattice({0: [1]}) + sage: P.relabel(lambda n: n+1) Finite join-semilattice containing 2 elements .. NOTE:: @@ -6213,10 +6227,10 @@ def canonical_label(self, algorithm=None): sage: D = DiGraph({'a':['b','c']}) sage: P = Poset(D) - sage: ML = MeetSemilattice(D) # optional - sage.modules + sage: ML = MeetSemilattice(D) sage: P.canonical_label() Finite poset containing 3 elements - sage: ML.canonical_label() # optional - sage.modules + sage: ML.canonical_label() Finite meet-semilattice containing 3 elements .. SEEALSO:: @@ -6293,8 +6307,8 @@ def with_linear_extension(self, linear_extension): (Semi)lattice remains (semi)lattice with new linear extension:: - sage: L = LatticePoset(P) # optional - sage.modules - sage: Q = L.with_linear_extension([1,3,2,6,4,12]); Q # optional - sage.modules + sage: L = LatticePoset(P) + sage: Q = L.with_linear_extension([1,3,2,6,4,12]); Q Finite lattice containing 6 elements with distinguished linear extension .. NOTE:: @@ -6354,9 +6368,9 @@ def subposet(self, elements): A subposet of a non-facade poset is again a non-facade poset:: - sage: P = posets.PentagonPoset(facade=False) # optional - sage.modules - sage: Q = P.subposet([0, 1, 2, 4]) # optional - sage.modules - sage: Q(1) < Q(2) # optional - sage.modules + sage: P = posets.PentagonPoset(facade=False) + sage: Q = P.subposet([0, 1, 2, 4]) + sage: Q(1) < Q(2) False TESTS:: @@ -6413,8 +6427,8 @@ def random_subposet(self, p): TESTS:: - sage: P = posets.IntegerPartitions(4) # optional - sage.combinat - sage: P.random_subposet(1) == P # optional - sage.combinat + sage: P = posets.IntegerPartitions(4) # needs sage.combinat + sage: P.random_subposet(1) == P # needs sage.combinat True """ from sage.misc.randstate import current_randstate @@ -6709,17 +6723,19 @@ def order_ideal_plot(self, elements): EXAMPLES:: + sage: # needs sage.plot sage: P = Poset((divisors(1000), attrcall("divides"))) - sage: P.order_ideal_plot([20, 25]) # optional - sage.plot + sage: P.order_ideal_plot([20, 25]) Graphics object consisting of 41 graphics primitives TESTS:: + sage: # needs sage.plot sage: P = Poset() # Test empty poset - sage: P.order_ideal_plot([]) # optional - sage.plot + sage: P.order_ideal_plot([]) Graphics object consisting of 0 graphics primitives sage: C = posets.ChainPoset(5) - sage: C.order_ideal_plot([]) # optional - sage.plot + sage: C.order_ideal_plot([]) Graphics object consisting of 10 graphics primitives """ order_ideal = self.order_ideal(elements) @@ -6905,25 +6921,25 @@ def linear_extensions_graph(self): EXAMPLES:: sage: N = Poset({1: [3, 4], 2: [4]}) - sage: G = N.linear_extensions_graph(); G # optional - sage.modules + sage: G = N.linear_extensions_graph(); G Graph on 5 vertices - sage: G.neighbors(N.linear_extension([1,2,3,4])) # optional - sage.modules + sage: G.neighbors(N.linear_extension([1,2,3,4])) [[2, 1, 3, 4], [1, 3, 2, 4], [1, 2, 4, 3]] sage: chevron = Poset({1: [2, 6], 2: [3], 4: [3, 5], 6: [5]}) - sage: G = chevron.linear_extensions_graph(); G # optional - sage.modules + sage: G = chevron.linear_extensions_graph(); G Graph on 22 vertices - sage: G.size() # optional - sage.modules + sage: G.size() 36 TESTS:: - sage: Poset().linear_extensions_graph() # optional - sage.modules + sage: Poset().linear_extensions_graph() Graph on 1 vertex sage: A4 = posets.AntichainPoset(4) - sage: G = A4.linear_extensions_graph() # optional - sage.modules - sage: G.is_regular() # optional - sage.modules + sage: G = A4.linear_extensions_graph() + sage: G.is_regular() True """ from sage.graphs.graph import Graph @@ -6952,7 +6968,7 @@ def maximal_antichains(self): sage: [sorted(anti) for anti in P.maximal_antichains()] [['a'], ['b', 'c'], ['c', 'd', 'e']] - sage: posets.PentagonPoset().maximal_antichains() # optional - sage.modules + sage: posets.PentagonPoset().maximal_antichains() [[0], [1, 2], [1, 3], [4]] .. SEEALSO:: :meth:`antichains`, :meth:`maximal_chains` @@ -7087,10 +7103,10 @@ def order_complex(self, on_ints=False): Simplicial complex with vertex set (0, 1, 2, 3, 4, 5, 6, 7) and 6 facets sage: S.f_vector() [1, 8, 19, 18, 6] - sage: S.homology() # S is contractible # optional - sage.modules + sage: S.homology() # S is contractible {0: 0, 1: 0, 2: 0, 3: 0} sage: Q = P.subposet([1,2,3,4,5,6]) - sage: Q.order_complex().homology() # a circle # optional - sage.modules + sage: Q.order_complex().homology() # a circle {0: 0, 1: Z} sage: P = Poset((divisors(15), attrcall("divides")), facade = True) @@ -7144,17 +7160,17 @@ def order_polytope(self): EXAMPLES:: sage: P = posets.AntichainPoset(3) - sage: Q = P.order_polytope(); Q # optional - sage.geometry.polyhedron + sage: Q = P.order_polytope(); Q # needs sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: Q = P.order_polytope(); Q # optional - sage.modules sage.geometry.polyhedron + sage: P = posets.PentagonPoset() + sage: Q = P.order_polytope(); Q # needs sage.geometry.polyhedron A 5-dimensional polyhedron in ZZ^5 defined as the convex hull of 8 vertices sage: P = Poset([[1,2,3],[[1,2],[1,3]]]) - sage: Q = P.order_polytope() # optional - sage.geometry.polyhedron - sage: Q.contains((1,0,0)) # optional - sage.geometry.polyhedron + sage: Q = P.order_polytope() # needs sage.geometry.polyhedron + sage: Q.contains((1,0,0)) # needs sage.geometry.polyhedron False - sage: Q.contains((0,1,1)) # optional - sage.geometry.polyhedron + sage: Q.contains((0,1,1)) # needs sage.geometry.polyhedron True """ from sage.geometry.polyhedron.constructor import Polyhedron @@ -7190,10 +7206,10 @@ def chain_polytope(self): EXAMPLES:: sage: P = posets.AntichainPoset(3) - sage: Q = P.chain_polytope();Q # optional - sage.geometry.polyhedron + sage: Q = P.chain_polytope();Q # needs sage.geometry.polyhedron A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: Q = P.chain_polytope();Q # optional - sage.modules sage.geometry.polyhedron + sage: P = posets.PentagonPoset() + sage: Q = P.chain_polytope();Q # needs sage.geometry.polyhedron A 5-dimensional polyhedron in ZZ^5 defined as the convex hull of 8 vertices """ from sage.geometry.polyhedron.constructor import Polyhedron @@ -7234,8 +7250,8 @@ def zeta_polynomial(self): sage: posets.ChainPoset(3).zeta_polynomial() 1/2*q^2 + 1/2*q - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.zeta_polynomial() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.zeta_polynomial() 1/6*q^3 + q^2 - 1/6*q sage: P = posets.DiamondPoset(5) @@ -7286,13 +7302,13 @@ def M_triangle(self): EXAMPLES:: sage: P = posets.DiamondPoset(5) - sage: P.M_triangle() # optional - sage.combinat + sage: P.M_triangle() # needs sage.combinat M: x^2*y^2 - 3*x*y^2 + 3*x*y + 2*y^2 - 3*y + 1 TESTS:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.M_triangle() # optional - sage.combinat sage.modules + sage: P = posets.PentagonPoset() + sage: P.M_triangle() # needs sage.combinat Traceback (most recent call last): ... ValueError: the poset is not graded @@ -7398,8 +7414,8 @@ def h_polynomial(self): EXAMPLES:: - sage: P = posets.AntichainPoset(3).order_ideals_lattice() # optional - sage.modules - sage: P.h_polynomial() # optional - sage.modules + sage: P = posets.AntichainPoset(3).order_ideals_lattice() + sage: P.h_polynomial() q^3 + 4*q^2 + q sage: P = posets.DiamondPoset(5) sage: P.h_polynomial() @@ -7699,13 +7715,13 @@ def order_polynomial(self): EXAMPLES:: sage: P = posets.AntichainPoset(3) - sage: P.order_polynomial() # optional - sage.modules sage.rings.finite_rings + sage: P.order_polynomial() q^3 sage: P = posets.ChainPoset(3) - sage: f = P.order_polynomial(); f # optional - sage.modules sage.rings.finite_rings + sage: f = P.order_polynomial(); f 1/6*q^3 + 1/2*q^2 + 1/3*q - sage: [f(i) for i in range(4)] # optional - sage.modules sage.rings.finite_rings + sage: [f(i) for i in range(4)] [0, 1, 4, 10] .. SEEALSO:: :meth:`order_polytope` @@ -7731,8 +7747,8 @@ def degree_polynomial(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.degree_polynomial() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.degree_polynomial() x^2 + 3*x*y + y^2 sage: P = posets.BooleanLattice(4) @@ -7974,17 +7990,18 @@ def is_slender(self, certificate=False): sage: P.is_slender() False - sage: W = WeylGroup(['A', 2]) # optional - sage.groups - sage: G = W.bruhat_poset() # optional - sage.groups - sage: G.is_slender() # optional - sage.groups + sage: # needs sage.groups + sage: W = WeylGroup(['A', 2]) + sage: G = W.bruhat_poset() + sage: G.is_slender() True - sage: W = WeylGroup(['A', 3]) # optional - sage.groups - sage: G = W.bruhat_poset() # optional - sage.groups - sage: G.is_slender() # optional - sage.groups + sage: W = WeylGroup(['A', 3]) + sage: G = W.bruhat_poset() + sage: G.is_slender() True - sage: P = posets.IntegerPartitions(6) # optional - sage.combinat - sage: P.is_slender(certificate=True) # optional - sage.combinat + sage: P = posets.IntegerPartitions(6) # needs sage.combinat + sage: P.is_slender(certificate=True) # needs sage.combinat (False, ((6,), (3, 2, 1))) TESTS:: @@ -8028,7 +8045,7 @@ def is_sperner(self): EXAMPLES:: - sage: posets.SetPartitions(3).is_sperner() # optional - sage.combinat + sage: posets.SetPartitions(3).is_sperner() # needs sage.combinat True sage: P = Poset({0:[3,4,5],1:[5],2:[5]}) @@ -8037,7 +8054,7 @@ def is_sperner(self): TESTS:: - sage: posets.PentagonPoset().is_sperner() # optional - sage.modules + sage: posets.PentagonPoset().is_sperner() Traceback (most recent call last): ... ValueError: the poset is not ranked @@ -8084,33 +8101,33 @@ def is_eulerian(self, k=None, certificate=False): sage: P = Poset({0: [1, 2, 3], 1: [4, 5], 2: [4, 6], 3: [5, 6], ....: 4: [7, 8], 5: [7, 8], 6: [7, 8], 7: [9], 8: [9]}) - sage: P.is_eulerian() # optional - sage.modules sage.rings.finite_rings + sage: P.is_eulerian() True sage: P = Poset({0: [1, 2, 3], 1: [4, 5, 6], 2: [4, 6], 3: [5,6], ....: 4: [7], 5:[7], 6:[7]}) - sage: P.is_eulerian() # optional - sage.modules sage.rings.finite_rings + sage: P.is_eulerian() False Canonical examples of Eulerian posets are the face lattices of convex polytopes:: - sage: P = polytopes.cube().face_lattice() # optional - sage.geometry.polyhedron - sage: P.is_eulerian() # optional - sage.geometry.polyhedron sage.rings.finite_rings + sage: P = polytopes.cube().face_lattice() # needs sage.geometry.polyhedron + sage: P.is_eulerian() # needs sage.geometry.polyhedron True A poset that is 3- but not 4-eulerian:: sage: P = Poset(DiGraph('MWW@_?W?@_?W??@??O@_?W?@_?W?@??O??')); P Finite poset containing 14 elements - sage: P.is_eulerian(k=3) # optional - sage.modules + sage: P.is_eulerian(k=3) True - sage: P.is_eulerian(k=4) # optional - sage.modules + sage: P.is_eulerian(k=4) False Getting an interval that is not Eulerian:: sage: P = posets.DivisorLattice(12) - sage: P.is_eulerian(certificate=True) # optional - sage.modules + sage: P.is_eulerian(certificate=True) (False, (1, 4)) TESTS:: @@ -8120,15 +8137,15 @@ def is_eulerian(self, k=None, certificate=False): ... ValueError: the poset is not bounded - sage: Poset({1: []}).is_eulerian() # optional - sage.modules + sage: Poset({1: []}).is_eulerian() True - sage: posets.PentagonPoset().is_eulerian() # optional - sage.modules + sage: posets.PentagonPoset().is_eulerian() Traceback (most recent call last): ... ValueError: the poset is not graded - sage: posets.BooleanLattice(3).is_eulerian(k=123, certificate=True) # optional - sage.modules + sage: posets.BooleanLattice(3).is_eulerian(k=123, certificate=True) (True, None) """ if k is not None: @@ -8346,7 +8363,6 @@ def frank_network(self): - Darij Grinberg (2013-05-09) """ - from sage.graphs.digraph import DiGraph P0 = [(0, i) for i in self] pdict = {(-1, 0): P0, (2, 0): []} for i in self: @@ -8374,18 +8390,19 @@ def greene_shape(self): EXAMPLES:: + sage: # needs sage.combinat sage: P = Poset([[3,2,1], [[3,1],[2,1]]]) - sage: P.greene_shape() # optional - sage.combinat + sage: P.greene_shape() [2, 1] sage: P = Poset([[1,2,3,4], [[1,4],[2,4],[4,3]]]) - sage: P.greene_shape() # optional - sage.combinat + sage: P.greene_shape() [3, 1] sage: P = Poset([[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22], ....: [[1,4],[2,4],[4,3]]]) - sage: P.greene_shape() # optional - sage.combinat + sage: P.greene_shape() [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] sage: P = Poset([[],[]]) - sage: P.greene_shape() # optional - sage.combinat + sage: P.greene_shape() [] AUTHOR: @@ -8393,15 +8410,15 @@ def greene_shape(self): - Darij Grinberg (2013-05-09) """ from sage.combinat.partition import Partition - (G, a) = self.frank_network() + G, a = self.frank_network() n = len(self) chron = _ford_fulkerson_chronicle(G, (-1, 0), (2, 0), a) size = 0 ps = [] part = 0 - (pold, vold) = (0, 0) + pold, vold = (0, 0) while size != n: - (p, v) = next(chron) + p, v = next(chron) if v > vold: size += p if part > 0: @@ -8468,41 +8485,41 @@ def p_partition_enumerator(self, tup, R, weights=None, check=False): EXAMPLES:: sage: P = Poset([[1,2,3,4],[[1,4],[2,4],[4,3]]]) - sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True); FP # optional - sage.combinat + sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, check=True); FP # needs sage.combinat 2*M[1, 1, 1, 1] + 2*M[1, 2, 1] + M[2, 1, 1] + M[3, 1] - sage: expansion = FP.expand(5) # optional - sage.combinat - sage: xs = expansion.parent().gens() # optional - sage.combinat - sage: expansion == sum(xs[a]*xs[b]*xs[c]*xs[d] # optional - sage.combinat + sage: expansion = FP.expand(5) # needs sage.combinat + sage: xs = expansion.parent().gens() # needs sage.combinat + sage: expansion == sum(xs[a]*xs[b]*xs[c]*xs[d] # needs sage.combinat ....: for a in range(5) for b in range(5) ....: for c in range(5) for d in range(5) ....: if a <= b and c <= b and b < d) True sage: P = Poset([[],[]]) - sage: FP = P.p_partition_enumerator((), QQ, check=True); FP # optional - sage.combinat + sage: FP = P.p_partition_enumerator((), QQ, check=True); FP # needs sage.combinat M[] With the ``weights`` parameter:: sage: P = Poset([[1,2,3,4],[[1,4],[2,4],[4,3]]]) - sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, # optional - sage.combinat + sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, # needs sage.combinat ....: weights={1: 1, 2: 2, 3: 1, 4: 1}, check=True); FP M[1, 2, 1, 1] + M[1, 3, 1] + M[2, 1, 1, 1] + M[2, 2, 1] + M[3, 1, 1] + M[4, 1] - sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, # optional - sage.combinat + sage: FP = P.p_partition_enumerator((3,1,2,4), QQ, # needs sage.combinat ....: weights={2: 2}, check=True); FP M[1, 2, 1, 1] + M[1, 3, 1] + M[2, 1, 1, 1] + M[2, 2, 1] + M[3, 1, 1] + M[4, 1] sage: P = Poset([['a','b','c'], [['a','b'], ['a','c']]]) - sage: FP = P.p_partition_enumerator(('b','c','a'), QQ, # optional - sage.combinat + sage: FP = P.p_partition_enumerator(('b','c','a'), QQ, # needs sage.combinat ....: weights={'a': 3, 'b': 5, 'c': 7}, check=True); FP M[3, 5, 7] + M[3, 7, 5] + M[3, 12] sage: P = Poset([['a','b','c'], [['a','c'], ['b','c']]]) - sage: FP = P.p_partition_enumerator(('b','c','a'), QQ, # optional - sage.combinat + sage: FP = P.p_partition_enumerator(('b','c','a'), QQ, # needs sage.combinat ....: weights={'a': 3, 'b': 5, 'c': 7}, check=True); FP M[3, 5, 7] + M[3, 12] + M[5, 3, 7] + M[8, 7] - sage: FP = P.p_partition_enumerator(('a','b','c'), QQ, # optional - sage.combinat + sage: FP = P.p_partition_enumerator(('a','b','c'), QQ, # needs sage.combinat ....: weights={'a': 3, 'b': 5, 'c': 7}, check=True); FP M[3, 5, 7] + M[3, 12] + M[5, 3, 7] + M[5, 10] + M[8, 7] + M[15] """ @@ -8585,18 +8602,18 @@ def completion_by_cuts(self): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P.completion_by_cuts().is_isomorphic(P) # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P.completion_by_cuts().is_isomorphic(P) True sage: Y = Poset({1: [2], 2: [3, 4]}) - sage: trafficsign = LatticePoset({1: [2], 2: [3, 4], 3: [5], 4: [5]}) # optional - sage.modules - sage: L = Y.completion_by_cuts() # optional - sage.modules - sage: L.is_isomorphic(trafficsign) # optional - sage.modules + sage: trafficsign = LatticePoset({1: [2], 2: [3, 4], 3: [5], 4: [5]}) + sage: L = Y.completion_by_cuts() + sage: L.is_isomorphic(trafficsign) True sage: P = posets.SymmetricGroupBruhatOrderPoset(3) - sage: Q = P.completion_by_cuts(); Q # optional - sage.modules + sage: Q = P.completion_by_cuts(); Q Finite lattice containing 7 elements .. SEEALSO:: @@ -8625,7 +8642,7 @@ def incidence_algebra(self, R, prefix='I'): EXAMPLES:: sage: P = posets.BooleanLattice(4) - sage: P.incidence_algebra(QQ) # optional - sage.modules + sage: P.incidence_algebra(QQ) Incidence algebra of Finite lattice containing 16 elements over Rational Field """ @@ -8747,7 +8764,7 @@ def kazhdan_lusztig_polynomial(self, x=None, y=None, q=None, canonical_labels=No sage: y = '3421' sage: L.kazhdan_lusztig_polynomial(x, y) -q + 1 - sage: L.kazhdan_lusztig_polynomial(x, y, var('t')) # optional - sage.symbolic + sage: L.kazhdan_lusztig_polynomial(x, y, var('t')) # needs sage.symbolic -t + 1 AUTHORS: @@ -8849,8 +8866,8 @@ def _macaulay2_init_(self, macaulay2=None): EXAMPLES:: - sage: P = posets.PentagonPoset() # optional - sage.modules - sage: P._macaulay2_init_() # optional - sage.modules + sage: P = posets.PentagonPoset() + sage: P._macaulay2_init_() 'needsPackage "Posets";poset({0,1,2,3,4},{{0,1},{0,2},{1,4},{2,3},{3,4}})' sage: P = Poset({1:[2],2:[]}) @@ -8919,9 +8936,9 @@ def __contains__(self, P): """ EXAMPLES:: - sage: posets.PentagonPoset() in Posets(5) # optional - sage.modules + sage: posets.PentagonPoset() in Posets(5) True - sage: posets.PentagonPoset() in Posets(3) # optional - sage.modules + sage: posets.PentagonPoset() in Posets(3) False sage: 1 in Posets(3) False @@ -9090,8 +9107,6 @@ def _ford_fulkerson_chronicle(G, s, t, a): sage: next(ffc) (11, 2) """ - from sage.graphs.digraph import DiGraph - # pi: potential function as a dictionary. pi = {v: 0 for v in G.vertex_iterator()} # p: value of the potential pi.