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.

Definition at line 61 of file unionfind.h.

Public Member Functions

int find (T a)
 Returns the index of the element's component.
int insert (T a)
 Insert 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.

Definition at line 81 of file unionfind.h.

Here is the call graph for this function:

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.

Definition at line 113 of file unionfind.h.

bool join a,
b
[inline]
 

This is the union operation of the Union-Find structure. Joins the component of elemenent a and component of element b. If a and b are in the same component then it returns false otherwise it returns true.

Definition at line 130 of file unionfind.h.

Here is the call graph for this function:

int size a  )  [inline]
 

Returns the size of the component of element a.

Definition at line 155 of file unionfind.h.

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Sat Mar 19 10:58:55 2005 for LEMON by  doxygen 1.4.1