Some fast computations for finite posets¶
- class sage.combinat.posets.hasse_cython.IncreasingChains(positions, element_constructor, exclude, conversion=None)¶
Bases:
RecursivelyEnumeratedSet_forestThe enumerated set of increasing chains.
INPUT:
positions– list of sets of integers describing the poset, as given by the lazy attribute_leq_storageof Hasse diagramselement_constructor– used to determine the type of chains, for examplelistortupleexclude– list of integers that should not belong to the chainsconversion– (optional) list of elements of the poset
If
conversionis provided, it is used to convert chain elements to elements of this list.EXAMPLES:
sage: from sage.combinat.posets.hasse_cython import IncreasingChains sage: D = IncreasingChains([{0,1},{1}], list, []); D An enumerated set with a forest structure sage: D.cardinality() 4 sage: list(D) [[], [0], [0, 1], [1]]
>>> from sage.all import * >>> from sage.combinat.posets.hasse_cython import IncreasingChains >>> D = IncreasingChains([{Integer(0),Integer(1)},{Integer(1)}], list, []); D An enumerated set with a forest structure >>> D.cardinality() 4 >>> list(D) [[], [0], [0, 1], [1]]
- children(chain)¶
Return the children of a chain, by adding one largest element.
EXAMPLES:
sage: from sage.combinat.posets.hasse_cython import IncreasingChains sage: D = IncreasingChains([{0,1},{1}], list, []) sage: D.children((0,)) [(0, 1)] sage: P = Poset({'a':['b'],'b':[]}) sage: next(iter(P.chains())) []
>>> from sage.all import * >>> from sage.combinat.posets.hasse_cython import IncreasingChains >>> D = IncreasingChains([{Integer(0),Integer(1)},{Integer(1)}], list, []) >>> D.children((Integer(0),)) [(0, 1)] >>> P = Poset({'a':['b'],'b':[]}) >>> next(iter(P.chains())) []
- post_process(chain)¶
Create a chain from the internal object.
If
conversionwas provided, it first converts elements of the chain to elements of this list.Then the given
element_constructoris applied to the chain.EXAMPLES:
sage: from sage.combinat.posets.hasse_cython import IncreasingChains sage: D = IncreasingChains([{0,1},{1}], list, []) sage: D.post_process((0,1)) [0, 1] sage: P = Poset({'a':['b'],'b':[]}) sage: list(P.chains()) [[], ['a'], ['a', 'b'], ['b']]
>>> from sage.all import * >>> from sage.combinat.posets.hasse_cython import IncreasingChains >>> D = IncreasingChains([{Integer(0),Integer(1)},{Integer(1)}], list, []) >>> D.post_process((Integer(0),Integer(1))) [0, 1] >>> P = Poset({'a':['b'],'b':[]}) >>> list(P.chains()) [[], ['a'], ['a', 'b'], ['b']]