51 int size(
int setId)
const;
59 int find(
int elementId);
61 int join(
int setId1,
int setId2);
std::vector< int > getSetIds() const
return a list of valid set ids
Definition: drwnDisjointSets.cpp:151
drwnDisjointSets(unsigned int count=0)
construct a disjoint dataset with count nodes
Definition: drwnDisjointSets.cpp:26
drwnDisjointSets & operator=(const drwnDisjointSets &dset)
assignment operator
Definition: drwnDisjointSets.cpp:165
int join(int setId1, int setId2)
join two sets and return the joined set id (either setId1 or setId2)
Definition: drwnDisjointSets.cpp:120
int find(int elementId)
find which set a particular node belongs to
Definition: drwnDisjointSets.cpp:87
void add(int count)
add count (disconnected) nodes
Definition: drwnDisjointSets.cpp:73
Implements a forest of disjoint sets abstract data type.
Definition: drwnDisjointSets.h:27
std::vector< node_t > _nodes
list of nodes
Definition: drwnDisjointSets.h:38
Definition: drwnDisjointSets.h:29
int sets() const
return the number of disjoint sets
Definition: drwnDisjointSets.h:53
int _nSets
number of sets in the forest
Definition: drwnDisjointSets.h:37
~drwnDisjointSets()
destructor
Definition: drwnDisjointSets.cpp:49
int _nElements
number of elements in the forest
Definition: drwnDisjointSets.h:36
int size() const
return the total number of nodes in the disjoint set
Definition: drwnDisjointSets.h:49
std::set< int > getMembers(int setId)
get the ids of nodes in set with id setId
Definition: drwnDisjointSets.cpp:62