Class Cover

Class Documentation

class Cover

Implements a cover of a set, i.e. an assignment of its elements to possibly overlapping subsets.

Public Functions

Cover()

Default constructor

Cover(index z)

Create a new cover data structure for elements up to a maximum element index.

Parameters:

z[in] maximum index

Cover(const Partition &p)

Creates a new cover data structure which contains the given partition.

Parameters:

p[in] The partition to construct the cover from

inline std::set<index> &operator[](const index &e)

Index operator.

Parameters:

e[in] an element

inline const std::set<index> &operator[](const index &e) const

Index operator for const instances of this class.

Parameters:

e[in] an element

inline std::set<index> subsetsOf(index e) const

Return the ids of subsets in which the element e is contained.

Parameters:

e[in] an element

Returns:

A set of subset ids in which e is contained.

bool contains(index e) const

Check if cover assigns a valid subset to the element e.

Parameters:

e – an element.

Returns:

true, if e is assigned to a valid subset, false otherwise.

bool inSameSubset(index e1, index e2) const

Check if two elements e1 and e2 belong to the same subset.

Parameters:
  • e1 – an element.

  • e2 – an element.

Returns:

true, if e1 and e2 belong to the same subset, false otherwise.

std::set<index> getMembers(index s) const

Get the members of a specific subset s.

Returns:

The set of members of subset s.

void addToSubset(index s, index e)

Add the (previously unassigned) element e to the set s.

Parameters:
  • s[in] a subset

  • e[in] an element

void removeFromSubset(index s, index e)

Remove the element e from the set s.

Parameters:
  • s[in] a subset

  • e[in] an element

void moveToSubset(index s, index e)

Move the element e to subset s, i.e. remove it from all other subsets and place it in the subset.

Parameters:
  • s[in] a subset

  • e[in] an element

index toSingleton(index e)

Creates a singleton set containing the element e and returns the index of the new set.

Parameters:

e[in] an element

Returns:

The index of the new set.

void allToSingletons()

Assigns every element to a singleton set. Set id is equal to element id.

void mergeSubsets(index s, index t)

Assigns the elements from both sets to a new set.

Parameters:
  • s[in] a subset

  • t[in] a subset

index upperBound() const

Get an upper bound for the subset ids that have been assigned. (This is the maximum id + 1.)

Returns:

An upper bound.

index lowerBound() const

Get a lower bound for the subset ids that have been assigned.

Returns:

A lower bound.

std::vector<count> subsetSizes() const

Get a list of subset sizes. Indices do not necessarily correspond to subset ids.

Returns:

A list of subset sizes.

std::map<index, count> subsetSizeMap() const

Get a map from subset id to size of the subset.

Returns:

A map from subset id to size of the subset.

count numberOfSubsets() const

Get the current number of sets in this cover.

Returns:

The number of sets in this cover.

count numberOfElements() const

Get the current number of elements in this cover.

Returns:

The current number of elements.

index extend()

Add an additional element (node).

std::set<index> getSubsetIds() const

Get the ids of nonempty subsets.

Returns:

A set of ids of nonempty subsets.

void setUpperBound(index upper)

Sets an upper bound for the subset ids that CAN be assigned.

Parameters:

upper[in] highest assigned subset ID + 1

template<typename Callback>
inline void forEntries(Callback func) const

Iterate over all entries (node, subset ID of node) and execute callback function func (lambda closure).

Parameters:

func – Takes parameters (node, index)

template<typename Callback>
inline void parallelForEntries(Callback handle) const

Iterate over all entries (node, subset ID of node) in parallel and execute callback function func (lambda closure).

Parameters:

func – Takes parameters (node, index)