disjoint
is a package for the Go programming language that implements a disjoint-set data structure (also known as a union-find data structure). Disjoint sets are collections of unordered elements in which an element belongs to exactly one set at a time. Sets can be merged destructively, meaning that the the original sets cease to exist once their union is taken. And elements can be compared for belonging to the same set. These operations run in amortized near-constant time.
disjoint
is a Go module and therefore should be installed with
go get github.com/spakin/disjoint/v2
and imported with
import "github.com/spakin/disjoint/v2"
See the disjoint
API documentation for details and examples.