> For the complete documentation index, see [llms.txt](https://welchj.gitbook.io/cp-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://welchj.gitbook.io/cp-notes/advanced/disjoint-set-union-union-find.md).

# Disjoint Set Union (Union Find)

DSU

**The Disjoint Set Union (DSU)** data structure, which allows you to add edges to a graph and test whether two vertices of the graph are connected.

[Here](https://csacademy.com/lesson/disjoint_data_sets) is a great source of explaining the logics behind DSU data structure (including template code).
