#include <lemon/unionfind.h>
It is primarily used in Kruskal algorithm for finding minimal cost spanning tree in a graph.
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. |
|
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:
|
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. |
|
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:
|
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: