template<typename V, typename IM, typename Comp = std::less<V>>
class lemon::HeapUnionFind< V, IM, Comp >
A Union-Find data structure implementation which is able to store a priority for each item and retrieve the minimum of each class. In addition, it supports the joining and splitting the components. If you don't need this feature then you makes better to use the UnionFind class which is more efficient.
The union-find data strcuture based on a (2, 16)-tree with a tournament minimum selection on the internal nodes. The insert operation takes O(1), the find, set, decrease and increase takes O(log(n)), where n is the number of nodes in the current component. The complexity of join and split is O(log(n)*k), where n is the sum of the number of the nodes and k is the number of joined components or the number of the components after the split.
- Precondition
- You need to add all the elements by the insert() method.
|
bool | alive (int cls) const |
| Returns true when the given class is alive.
|
|
bool | trivial (int cls) const |
| Returns true when the given class is trivial.
|
|
| HeapUnionFind (ItemIntMap &_index) |
| Constructs the union-find.
|
|
void | clear () |
| Clears the union-find data structure.
|
|
int | insert (const Item &item, const Value &prio) |
| Insert a new node into a new component.
|
|
int | find (const Item &item) const |
| The class of the item.
|
|
template<typename Iterator > |
int | join (Iterator begin, Iterator end) |
| Joins the classes.
|
|
template<typename Iterator > |
void | split (int cls, Iterator out) |
| Split the class to subclasses.
|
|
const Value & | operator[] (const Item &item) const |
|
void | set (const Item &item, const Value &prio) |
|
void | increase (const Item &item, const Value &prio) |
|
void | decrease (const Item &item, const Value &prio) |
|
const Value & | classPrio (int cls) const |
|
const Item & | classTop (int cls) const |
| Gives back the minimum priority item of the class.
|
|
const Item & | classRep (int id) const |
| Gives back a representant item of the class.
|
|