cyanial / unionfind

Implement an union-find in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Union-Find

Operatrions:

Initialization:

uf := unionfind.New(6)

parent: [0, 1, 2, 3, 4, 5] index: 0 1 2 3 4 5

Find

find parent of element x

// var p int
p = uf.Find(x)

Union

Merge two node into one set

// var p, q int
uf.Union(p, q)

About

Implement an union-find in Go.


Languages

Language:Go 100.0%