Elements of posets, lattices, semilattices, etc.

class sage.combinat.posets.elements.JoinSemilatticeElement(poset, element, vertex)
__add__(other)

Return the join of self and other in the lattice.

EXAMPLES:

sage: D = Posets.DiamondPoset(5)
sage: D(1) + D(2)
4
sage: D(1) + D(1)
1
sage: D(1) + D(4)
4
sage: D(1) + D(0)
1
class sage.combinat.posets.elements.LatticePosetElement(poset, element, vertex)
class sage.combinat.posets.elements.MeetSemilatticeElement(poset, element, vertex)
__mul__(other)

Return the meet of self and other in the lattice.

EXAMPLES:

sage: D = Posets.DiamondPoset(5)
sage: D(1) * D(2)
0
sage: D(1) * D(1)
1
sage: D(1) * D(0)
0
sage: D(1) * D(4)
1
class sage.combinat.posets.elements.PosetElement(poset, element, vertex)
__cmp__(other)

A default comparison of self with other.

Note

The rich comparison methods have been implemented for poset elements, so when a user asks for x < y, for example, rich comparison is used (that is, x.__lt__(y) is returned). This method is implemented because PosetElement inherits from Element, which requires __cmp__ to enable sorting by the cmp method.

If both self and other have the same parent poset, then the comparison is done in the poset. If the elements are incomparable in the poset, then 0 is returned. Note that, in particular, cmp(a,b) == cmp(b,a) if a and b are equal or incomparable in the poset.

TESTS:

sage: P = Poset([[1,2],[4],[3],[4],[]])
sage: P(0).__cmp__(P(4))
-1
sage: P(4).__cmp__(P(0))
1
sage: P(0).__cmp__(P(0))
0
sage: P(1).__cmp__(P(2))
0
sage: cmp(P(0),P(4))
-1
sage: cmp(P(4),P(0))
1
sage: cmp(P(0),P(0))
0
sage: cmp(P(1),P(2))
0
sage: cmp(P(2),P(1))
0
__eq__(other)

TESTS:

sage: P = Poset([[1,2],[4],[3],[4],[]])
sage: P(0).__eq__(P(4))
False
sage: from sage.combinat.posets.elements import PosetElement
sage: PosetElement(P,0,3) == PosetElement(P,0,3)
True
sage: PosetElement(P,1,3) == PosetElement(P,0,3)
False
sage: PosetElement(P,0,2) == PosetElement(P,0,3)
False
__ge__(other)

TESTS

sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
sage: P = Poset(dag)
sage: P(0).__ge__(P(5))
False
sage: P(5).__ge__(P(0))
True
sage: P(0).__ge__(P(0))
True
__gt__(other)

TESTS

sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
sage: P = Poset(dag)
sage: P(0).__gt__(P(5))
False
sage: P(5).__gt__(P(0))
True
sage: P(0).__gt__(P(0))
False
__init__(poset, element, vertex)

Establishes the parent-child relationship between poset and element, where element is associated to the vertex vertex of the Hasse diagram of the poset.

INPUT:

  • poset - a poset object
  • element - any object
  • vertex - a vertex of the Hasse diagram of the poset

TESTS:

sage: from sage.combinat.posets.elements import PosetElement
sage: P = Poset([[1,2],[4],[3],[4],[]])
sage: e = P(0)
sage: e.parent() is P
True
sage: e == loads(dumps(e))
True
__le__(other)

TESTS

sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
sage: P = Poset(dag)
sage: P(1) <= P(0)
False
sage: P(0) <= P(1)
False
sage: P(0) <= P(3)
True
sage: P(0) <= P(0)
True
__lt__(other)

TESTS

sage: dag = DiGraph({0:[2,3], 1:[3,4], 2:[5], 3:[5], 4:[5]})
sage: P = Poset(dag)
sage: P(0) < P(1)
False
sage: P(4) < P(1)
False
sage: P(0) < P(0)
False
__ne__(other)

TESTS:

sage: P = Poset([[1,2],[4],[3],[4],[]])
sage: P(0).__ne__(P(4))
True
sage: from sage.combinat.posets.elements import PosetElement
sage: PosetElement(P,0,3) != PosetElement(P,0,3)
False
sage: PosetElement(P,1,3) != PosetElement(P,0,3)
True
sage: PosetElement(P,0,2) != PosetElement(P,0,3)
True
__repr__()

TESTS:

sage: repr(Poset([[1,2],[4],[3],[4],[]])(0))
'0'
__weakref__
list of weak references to the object (if defined)
_cmp(other)

TESTS:

sage: P = Poset([[1,2],[4],[3],[4],[]])
sage: P(0)._cmp(P(4))
-1
sage: P(4)._cmp(P(0))
1
sage: P(0)._cmp(P(0))
0
sage: P(1)._cmp(P(2))

Previous topic

Hasse diagrams of posets

Next topic

SemiLattices and Lattices

This Page