size_t count
The number of disconnected sets.
size_t * parent
An array with each element's parent.
Weighted quick-union by rank with path compression by halving.
void union_find_delete(t_union_find *uf)
Deletes the union-find and frees all memory taken by its contents, or does nothing if the argument is...
size_t union_find_size(const t_union_find *uf)
Returns the number of elements in this union-find.
size_t union_find_find(const t_union_find *uf, size_t p)
Returns the canonical element of the set containing the specified element.
size_t union_find_count(const t_union_find *uf)
Returns the number of disconnected sets.
void union_find_union(t_union_find *uf, size_t p, size_t q)
Merges the set containing element p with the set containing element q.
t_union_find * union_find_new(size_t size)
Initializes a new union-find data structure of the specified size.
size_t * nchild
An array with the number of each element's children.
size_t size
The number of elements.