Vamonos.DataStructure.DisjointSet

Back

A disjoint set data structure for use in algorithms and widgets.

Constructor Arguments

onUpdate :: Function – optional

A function that does something to an element in the set when it the disjoint set is modified.

Public Interface

eachSet(f)

applies f to each set in the DisjointSet, along with its index

find(elem)

returns an integer representing the set with elem in it

getSets()

returns a list of all the sets in the DisjointSet.Sets are represented by lists. Note that some lists may be empty.

makeSet(elem)

creates a new set with elem

numSets()

returns the max number of sets that have existed

union(e1, e2)

joins the set containing e1 with the one containing e2