All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
NetworKit::Cover Class Reference

Implements a cover of a set, i.e. More...

#include <Cover.h>

Public Member Functions

 Cover ()
 Default constructor. More...
 
 Cover (index z)
 Create a new cover data structure for elements up to a maximum element index. More...
 
 Cover (const Partition &p)
 Creates a new cover data structure which contains the given partition. More...
 
virtual ~Cover ()=default
 Default destructor. More...
 
std::set< index > & operator[] (const index &e)
 Index operator. More...
 
const std::set< index > & operator[] (const index &e) const
 Index operator for const instances of this class. More...
 
std::set< indexsubsetsOf (index e) const
 Return the ids of subsets in which the element e is contained. More...
 
bool contains (index e) const
 Check if cover assigns a valid subset to the element e. More...
 
bool inSameSubset (index e1, index e2) const
 Check if two elements e1 and e2 belong to the same subset. More...
 
std::set< indexgetMembers (const index s) const
 Get the members of a specific subset s. More...
 
void addToSubset (index s, index e)
 Add the (previously unassigned) element e to the set s. More...
 
void removeFromSubset (index s, index e)
 Remove the element e from the set s. More...
 
void moveToSubset (index s, index e)
 Move the element e to subset s, i.e. More...
 
index toSingleton (index e)
 Creates a singleton set containing the element e and returns the index of the new set. More...
 
void allToSingletons ()
 Assigns every element to a singleton set. More...
 
void mergeSubsets (index s, index t)
 Assigns the elements from both sets to a new set. More...
 
index upperBound () const
 Get an upper bound for the subset ids that have been assigned. More...
 
index lowerBound () const
 Get a lower bound for the subset ids that have been assigned. More...
 
std::vector< countsubsetSizes () const
 Get a list of subset sizes. More...
 
std::map< index, countsubsetSizeMap () const
 Get a map from subset id to size of the subset. More...
 
count numberOfSubsets () const
 Get the current number of sets in this cover. More...
 
count numberOfElements () const
 Get the current number of elements in this cover. More...
 
std::set< indexgetSubsetIds () const
 Get the ids of nonempty subsets. More...
 
void setUpperBound (index upper)
 Sets an upper bound for the subset ids that CAN be assigned. More...
 
template<typename Callback >
void forEntries (Callback func) const
 Iterate over all entries (node, subset ID of node) and execute callback function func (lambda closure). More...
 
template<typename Callback >
void parallelForEntries (Callback handle) const
 Iterate over all entries (node, subset ID of node) in parallel and execute callback function func (lambda closure). More...
 

Detailed Description

Implements a cover of a set, i.e.

an assignment of its elements to possibly overlapping subsets.

Constructor & Destructor Documentation

NetworKit::Cover::Cover ( )

Default constructor.

NetworKit::Cover::Cover ( index  z)

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

Parameters
[in]zmaximum index
NetworKit::Cover::Cover ( const Partition p)

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

Parameters
[in]pThe partition to construct the cover from
virtual NetworKit::Cover::~Cover ( )
virtualdefault

Default destructor.

Member Function Documentation

void NetworKit::Cover::addToSubset ( index  s,
index  e 
)

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

Parameters
[in]sa subset
[in]ean element
void NetworKit::Cover::allToSingletons ( )

Assigns every element to a singleton set.

Set id is equal to element id.

bool NetworKit::Cover::contains ( index  e) const

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

Parameters
ean element.
Returns
true, if e is assigned to a valid subset, false otherwise.
template<typename Callback >
void NetworKit::Cover::forEntries ( Callback  func) const
inline

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

Parameters
funcTakes parameters (node, index)
std::set< index > NetworKit::Cover::getMembers ( const index  s) const

Get the members of a specific subset s.

Returns
The set of members of subset s.
std::set< index > NetworKit::Cover::getSubsetIds ( ) const

Get the ids of nonempty subsets.

Returns
A set of ids of nonempty subsets.
bool NetworKit::Cover::inSameSubset ( index  e1,
index  e2 
) const

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

Parameters
e1an element.
e2an element.
Returns
true, if e1 and e2 belong to the same subset, false otherwise.
index NetworKit::Cover::lowerBound ( ) const

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

Returns
A lower bound.
void NetworKit::Cover::mergeSubsets ( index  s,
index  t 
)

Assigns the elements from both sets to a new set.

Parameters
[in]sa subset
[in]ta subset
void NetworKit::Cover::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
[in]sa subset
[in]ean element
count NetworKit::Cover::numberOfElements ( ) const

Get the current number of elements in this cover.

Returns
The current number of elements.
count NetworKit::Cover::numberOfSubsets ( ) const

Get the current number of sets in this cover.

Returns
The number of sets in this cover.
std::set<index>& NetworKit::Cover::operator[] ( const index e)
inline

Index operator.

Parameters
[in]ean element
const std::set<index>& NetworKit::Cover::operator[] ( const index e) const
inline

Index operator for const instances of this class.

Parameters
[in]ean element
template<typename Callback >
void NetworKit::Cover::parallelForEntries ( Callback  handle) const
inline

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

Parameters
funcTakes parameters (node, index)
void NetworKit::Cover::removeFromSubset ( index  s,
index  e 
)

Remove the element e from the set s.

Parameters
[in]sa subset
[in]ean element
void NetworKit::Cover::setUpperBound ( index  upper)

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

Parameters
[in]upperhighest assigned subset ID + 1
std::map< index, count > NetworKit::Cover::subsetSizeMap ( ) const

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

Returns
A map from subset id to size of the subset.
std::vector< count > NetworKit::Cover::subsetSizes ( ) const

Get a list of subset sizes.

Indices do not necessarily correspond to subset ids.

Returns
A list of subset sizes.
std::set<index> NetworKit::Cover::subsetsOf ( index  e) const
inline

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

Parameters
[in]ean element
Returns
A set of subset ids in which e is contained.
index NetworKit::Cover::toSingleton ( index  e)

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

Parameters
[in]ean element
Returns
The index of the new set.
index NetworKit::Cover::upperBound ( ) const

Get an upper bound for the subset ids that have been assigned.

(This is the maximum id + 1.)

Returns
An upper bound.

The documentation for this class was generated from the following files: