Darwin
1.10(beta)
|
Implements a forest of disjoint sets abstract data type. More...
Classes | |
struct | _node_t |
Public Member Functions | |
drwnDisjointSets (unsigned int count=0) | |
construct a disjoint dataset with count nodes | |
drwnDisjointSets (const drwnDisjointSets &dset) | |
copy constructor | |
~drwnDisjointSets () | |
destructor | |
int | size () const |
return the total number of nodes in the disjoint set | |
int | size (int setId) const |
return the number of nodes in set setId | |
int | sets () const |
return the number of disjoint sets | |
std::set< int > | getMembers (int setId) |
get the ids of nodes in set with id setId | |
void | add (int count) |
add count (disconnected) nodes | |
int | find (int elementId) |
find which set a particular node belongs to | |
int | join (int setId1, int setId2) |
join two sets and return the joined set id (either setId1 or setId2 ) | |
std::vector< int > | getSetIds () const |
return a list of valid set ids | |
drwnDisjointSets & | operator= (const drwnDisjointSets &dset) |
assignment operator | |
Protected Types | |
typedef struct drwnDisjointSets::_node_t | node_t |
Protected Attributes | |
int | _nElements |
number of elements in the forest | |
int | _nSets |
number of sets in the forest | |
std::vector< node_t > | _nodes |
list of nodes | |
Implements a forest of disjoint sets abstract data type.
The elements are numbered from 0 to (size() - 1). Each element belongs to exactly one set. The sets have ID sparesly numbered in the range 0 to (size() - 1). To get the number of elements of each set, call size(id) with a valid set ID.