fcapy.poset.lattice
The module provides a lattice object from Order theory and its upper/lower semilattices.
An upper semilattice is a poset that contains a single top (join) element. A lower semilattice is a poset that contains a single bottom (meet) element. A lattice contains both a single top and a single bottom elements.
Classes
|
A class to represent a Lattice |
|
A class to represent Meet (or Lower) Semilattice |
|
A class to represent Join (or Upper) Semilattice |
- class fcapy.poset.lattice.Lattice(elements, leq_func, use_cache: bool = True, direct_subelements_dict=None)
A class to represent a Lattice
A lattice is a POSet with a single top (the biggest) and a single bottom (the smallest) elements
- add(element, fill_up_cache=True)
Add an
elementto semilattice. Automatically fill up the comparison caches if needed
- property bottom_element
An index of the bottom (the smallest) element of a semilattice
- property bottom_elements
A list of indexes of the bottom (the smallest) elements of a semilattice
- direct_sub_elements(element_index: int)
Return a set of indexes of closest elements of POSet smaller than element #``element_index``
Element
ais a direct sub element of elementbifa``<``band there is no elementcsuch thata``<``c``<``b
- property direct_sub_elements_dict
list`[indexes of closest elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- direct_super_elements(element_index: int)
Return a set of indexes of closest elements of POSet bigger than element #``element_index``
Element
ais a direct super element of elementbifa>``b`` and there is no elementcsuch thata>``c``>``b``
- property direct_super_elements_dict
list`[indexes of closest elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- property elements
A set of elements of the POSet
- fill_up_caches()
Fill up each cache of POSet
- fill_up_direct_subelements_cache()
Compute direct subelements of each element in a POSet
- fill_up_direct_superelements_cache()
Compute direct superelements of each element in a POSet
- fill_up_leq_cache()
Compare all the elements of POSet at once
- fill_up_subelements_cache()
Compute all subelements of each element in a POSet
- fill_up_superelements_cache()
Compute all superelements of each element in a POSet
- index(element)
Returns an index of the
elementin the list ofPOSet.elements
- infimum(element_indexes: Optional[Collection] = None)
Alias for self.meet_elements(element_indexes)
- join_elements(element_indexes: Optional[Collection] = None)
Return the smallest element from POSet bigger than all elements from
element_indexes
- leq_elements(a_index: int, b_index: int)
Compare two elements of POSet by their indexes
- property leq_func
A function to compare whether element
a` from the POSet is smaller than ``bor not
- meet_elements(element_indexes: Optional[Collection] = None)
Return the biggest element from POSet smaller than all elements from
element_indexes
- remove(element)
Remove and
elementfrom the semilattice
- sub_elements(element_index: int)
Return a set of indexes of elements of POSet smaller than element #``element_index``
- property sub_elements_dict
list`[indexes of all elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- super_elements(element_index: int)
Return a set of indexes of elements of POSet bigger than element #``element_index``
- property super_elements_dict
list`[indexes of all elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- supremum(element_indexes: Optional[Collection] = None)
Alias for self.join_elements(element_indexes)
- to_networkx(direction: str = 'down')
Construct networkx.Graph (or DiGraph) based on POSet relations and
direction
- property top_element
An index of the single top (the biggest) element of the semilattice
- property top_elements
The set of indexes of the top (the biggest) elements of the semilattice
- trace_element(element, direction: str)
Get the sets of all and direct superelements (or subelements) of an
elementin the POSet- Parameters
element – An element to compare POSet elements with (not necessary from the POSet itself)
direction ({'up', 'down'}) – If set ‘up’ then compute all (and direct) subelements of an
element, if set ‘down’ then compute all (and direct) superelements of anelement
- Returns
final_elements (set) – A set of direct super (or sub) elements of
elementin the POSettraced_elements (set) – A set of all super (or sub) elements of
elementin the POSet
- class fcapy.poset.lattice.LowerSemiLattice(elements, leq_func, use_cache: bool = True, direct_subelements_dict=None)
A class to represent Meet (or Lower) Semilattice
A meet (or lower) semilattice is a POSet with a single bottom (meet) element
- add(element, fill_up_cache=True)
Add an
elementto semilattice. Automatically fill up the comparison caches if needed
- property bottom_element
An index of the bottom (the smallest) element of a semilattice
- property bottom_elements
A list of indexes of the bottom (the smallest) elements of a semilattice
- direct_sub_elements(element_index: int)
Return a set of indexes of closest elements of POSet smaller than element #``element_index``
Element
ais a direct sub element of elementbifa``<``band there is no elementcsuch thata``<``c``<``b
- property direct_sub_elements_dict
list`[indexes of closest elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- direct_super_elements(element_index: int)
Return a set of indexes of closest elements of POSet bigger than element #``element_index``
Element
ais a direct super element of elementbifa>``b`` and there is no elementcsuch thata>``c``>``b``
- property direct_super_elements_dict
list`[indexes of closest elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- property elements
A set of elements of the POSet
- fill_up_caches()
Fill up each cache of POSet
- fill_up_direct_subelements_cache()
Compute direct subelements of each element in a POSet
- fill_up_direct_superelements_cache()
Compute direct superelements of each element in a POSet
- fill_up_leq_cache()
Compare all the elements of POSet at once
- fill_up_subelements_cache()
Compute all subelements of each element in a POSet
- fill_up_superelements_cache()
Compute all superelements of each element in a POSet
- index(element)
Returns an index of the
elementin the list ofPOSet.elements
- infimum(element_indexes: Optional[Collection] = None)
Alias for self.meet_elements(element_indexes)
- join_elements(element_indexes: Optional[Collection] = None)
Return the smallest element from POSet bigger than all elements from
element_indexes
- leq_elements(a_index: int, b_index: int)
Compare two elements of POSet by their indexes
- property leq_func
A function to compare whether element
a` from the POSet is smaller than ``bor not
- meet_elements(element_indexes: Optional[Collection] = None)
Return the biggest element from POSet smaller than all elements from
element_indexes
- remove(element)
Remove and
elementfrom the semilattice
- sub_elements(element_index: int)
Return a set of indexes of elements of POSet smaller than element #``element_index``
- property sub_elements_dict
list`[indexes of all elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- super_elements(element_index: int)
Return a set of indexes of elements of POSet bigger than element #``element_index``
- property super_elements_dict
list`[indexes of all elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- supremum(element_indexes: Optional[Collection] = None)
Alias for self.join_elements(element_indexes)
- to_networkx(direction: str = 'down')
Construct networkx.Graph (or DiGraph) based on POSet relations and
direction
- property top_elements
A list of the top (the biggest) elements in a POSet
- trace_element(element, direction: str)
Get the sets of all and direct superelements (or subelements) of an
elementin the POSet- Parameters
element – An element to compare POSet elements with (not necessary from the POSet itself)
direction ({'up', 'down'}) – If set ‘up’ then compute all (and direct) subelements of an
element, if set ‘down’ then compute all (and direct) superelements of anelement
- Returns
final_elements (set) – A set of direct super (or sub) elements of
elementin the POSettraced_elements (set) – A set of all super (or sub) elements of
elementin the POSet
- class fcapy.poset.lattice.UpperSemiLattice(elements, leq_func, use_cache: bool = True, direct_subelements_dict=None)
A class to represent Join (or Upper) Semilattice
A join (or upper) semilattice is a POSet with a single top (join) element
- add(element, fill_up_cache=True)
Add an
elementto semilattice. Automatically fill up the comparison caches if needed
- property bottom_elements
A list of the bottom (the smallest) elements in a POSet
- direct_sub_elements(element_index: int)
Return a set of indexes of closest elements of POSet smaller than element #``element_index``
Element
ais a direct sub element of elementbifa``<``band there is no elementcsuch thata``<``c``<``b
- property direct_sub_elements_dict
list`[indexes of closest elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- direct_super_elements(element_index: int)
Return a set of indexes of closest elements of POSet bigger than element #``element_index``
Element
ais a direct super element of elementbifa>``b`` and there is no elementcsuch thata>``c``>``b``
- property direct_super_elements_dict
list`[indexes of closest elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- property elements
A set of elements of the POSet
- fill_up_caches()
Fill up each cache of POSet
- fill_up_direct_subelements_cache()
Compute direct subelements of each element in a POSet
- fill_up_direct_superelements_cache()
Compute direct superelements of each element in a POSet
- fill_up_leq_cache()
Compare all the elements of POSet at once
- fill_up_subelements_cache()
Compute all subelements of each element in a POSet
- fill_up_superelements_cache()
Compute all superelements of each element in a POSet
- index(element)
Returns an index of the
elementin the list ofPOSet.elements
- infimum(element_indexes: Optional[Collection] = None)
Alias for self.meet_elements(element_indexes)
- join_elements(element_indexes: Optional[Collection] = None)
Return the smallest element from POSet bigger than all elements from
element_indexes
- leq_elements(a_index: int, b_index: int)
Compare two elements of POSet by their indexes
- property leq_func
A function to compare whether element
a` from the POSet is smaller than ``bor not
- meet_elements(element_indexes: Optional[Collection] = None)
Return the biggest element from POSet smaller than all elements from
element_indexes
- remove(element)
Remove and
elementfrom the semilattice
- sub_elements(element_index: int)
Return a set of indexes of elements of POSet smaller than element #``element_index``
- property sub_elements_dict
list`[indexes of all elements smaller than `element_index]
- Type
A dictionary of kind {element_index
- super_elements(element_index: int)
Return a set of indexes of elements of POSet bigger than element #``element_index``
- property super_elements_dict
list`[indexes of all elements bigger than `element_index]
- Type
A dictionary of kind {element_index
- supremum(element_indexes: Optional[Collection] = None)
Alias for self.join_elements(element_indexes)
- to_networkx(direction: str = 'down')
Construct networkx.Graph (or DiGraph) based on POSet relations and
direction
- property top_element
An index of the single top (the biggest) element of the semilattice
- property top_elements
The set of indexes of the top (the biggest) elements of the semilattice
- trace_element(element, direction: str)
Get the sets of all and direct superelements (or subelements) of an
elementin the POSet- Parameters
element – An element to compare POSet elements with (not necessary from the POSet itself)
direction ({'up', 'down'}) – If set ‘up’ then compute all (and direct) subelements of an
element, if set ‘down’ then compute all (and direct) superelements of anelement
- Returns
final_elements (set) – A set of direct super (or sub) elements of
elementin the POSettraced_elements (set) – A set of all super (or sub) elements of
elementin the POSet