The class implements a Union-Find data structure which is able to enumerate the components and the items in a component. If you don't need this feature then perhaps it's better to use the UnionFind class which is more efficient.
The union operation uses rank heuristic, while the find operation uses path compression.
#include <lemon/unionfind.h>
Classes | |
class | ClassIt |
LEMON style iterator for the representant items. More... | |
class | ItemIt |
LEMON style iterator for the items of a component. More... | |
Public Types | |
typedef IM | ItemIntMap |
| |
typedef ItemIntMap::Key | Item |
| |
Public Member Functions | |
int | insert (const Item &item) |
Inserts the given element into a new component. More... | |
void | insert (const Item &item, int cls) |
Inserts the given element into the component of the others. More... | |
void | clear () |
Clears the union-find data structure. More... | |
int | find (const Item &item) const |
Finds the component of the given element. More... | |
int | join (const Item &a, const Item &b) |
Joining the component of element a and element b. More... | |
int | size (int cls) const |
Returns the size of the class. More... | |
void | split (int cls) |
Splits up the component. More... | |
void | erase (const Item &item) |
Removes the given element from the structure. More... | |
Item | item (int cls) const |
Gives back a representant item of the component. More... | |
void | eraseClass (int cls) |
Removes the component of the given element from the structure. More... | |
|
inline |
This method creates a new component consisting only of the given element.
|
inline |
This methods inserts the element a into the component of the element comp.
|
inline |
Erase each item from the data structure.
|
inline |
The method returns the component id of the given element.
This is the union operation of the Union-Find structure. Joins the component of element a and component of element b. If a and b are in the same component then returns -1 else returns the remaining class.
|
inline |
Returns the size of the class.
|
inline |
Splitting the component into singleton components (component of size one).
|
inline |
Removes the element from its component and if the component becomes empty then removes that component from the component list.
|
inline |
Gives back a representant item of the component.
|
inline |
Removes the component of the given element from the structure.