orderedPartition

class corankco.partitioning.orderedPartition.OrderedPartition(partition: List[Set[Element]])

Class that implements usefull methods for an ordered partition. Note that in Kemeny rank aggregation, elements can be divided in sets of elements to consider independently

consistent_with(consensus: Consensus) bool

Compare the OrderedPartition object with a Consensus object :param consensus: the Consensus to compare with :return: True iif the Ordered partition and the consensus have the same number of elements, and for each i < j, for all x in subgroup i and y in subgroup j of the OrderedPartition, x is before y in the consensus. Note that if the Consensus object contains several consensus rankings, only the first one is considered

property elements: Set[Element]

Property to get a set of all the elements appearing in a group of the OrderedPartition :return: a set of all the elements appearing in a group of the OrderedPartition

get_group_index(index: int) Set[Element]

Get the i-th group of the OrderedPartition, that is the i-th Set of Elements of the partition :param index: the index of the part of the partition to get :return: the i-th group of the OrderedPartition, that is the i-th Set of Elements of the partition

in_same_group(element1: Element, element2: Element) bool

Return True iif the two elements in parameter are in the same group of the OrderedPartition object :param element1: :param element2: :return: True iif the two elements in parameter are in the same group of the OrderedPartition object

property nb_elements: int
Returns:

The number of total elements that is the sum of the number elements of each Set of the OrderedPartition

property partition: List[Set[Element]]
Returns:

The partition, that is the List of List of Element

which_index_is(element: Element) int

Method to get, given an Element, the int ID of its group :param element: The target element :return: the index i such that element is in the ith group of the partition. -1 if element is in no group