Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UnionFind Class Template Reference
[Auxiliary Data Structures]

#include <lemon/unionfind.h>

List of all members.


Detailed Description

template<typename T, typename TIntMap>
class lemon::UnionFind< T, TIntMap >

The class implements the Union-Find data structure. The union operation uses rank heuristic, while the find operation uses path compression. This is a very simple but efficient implementation, providing only four methods: join (union), find, insert and size. For more features see the UnionFindEnum class.

It is primarily used in Kruskal algorithm for finding minimal cost spanning tree in a graph.

See also:
kruskal()
Precondition:
The elements are automatically added only if the map given to the constructor was filled with -1's. Otherwise you need to add all the elements by the insert() method.
Bug:
It is not clear what the constructor parameter is used for.


Public Member Functions

int find (T a)
 Returns the index of the element's component.
int insert (T a)
 Inserts a new element into the structure.
bool join (T a, T b)
 Joining the components of element a and element b.
int size (T a)
 Returns the size of the component of element a.


Member Function Documentation

int find a  )  [inline]
 

The method returns the index of the element's component. This is an integer between zero and the number of inserted elements.

int insert a  )  [inline]
 

This method inserts a new element into the data structure.

It is not required to use this method: if the map given to the constructor was filled with -1's then it is called automatically on the first find or join.

The method returns the index of the new component.

bool join a,
b
[inline]
 

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 it returns false otherwise it returns true.

int size a  )  [inline]
 

Returns the size of the component of element a.


The documentation for this class was generated from the following file:
Generated on Sat Aug 27 14:16:14 2005 for LEMON by  doxygen 1.4.4