# /datum/unionfind

Union-find data structure.

This is a data structure that keeps track of a set of elements partitioned into a number of disjoint (non-overlapping) subsets. It provides near-constant-time operations (bounded by the inverse Ackermann function) to add new sets, to merge existing sets, and to determine whether elements are in the same set.

## Procs | |

Find | Finds the representative of the set that the given element is in. |
---|---|

InSameSet | Returns whether the given elements are in the same set. |

New | Creates a new union-find data structure with the given number of elements. The elements will be numbers from 1 to size. |

Union | Merges the sets that the given elements are in. |

## Proc Details

### Find

Finds the representative of the set that the given element is in.

### InSameSet

Returns whether the given elements are in the same set.

### New

Creates a new union-find data structure with the given number of elements. The elements will be numbers from 1 to size.

### Union

Merges the sets that the given elements are in.