union-find-array-0.1: union find data structure

Safe HaskellNone



class Monad m => MonadUnion l m | m -> l whereSource


new :: l -> m NodeSource

Add a new node, with a given label.

lookup :: Node -> m (Node, l)Source

Find the node representing a given node, and its label.

merge :: (l -> l -> (l, a)) -> Node -> Node -> m (Maybe a)Source

Merge two sets. The first argument is a function that takes the labels of the corresponding sets' representatives and computes a new label for the joined set. Returns Nothing if the given nodes are in the same set already.

annotate :: Node -> l -> m ()Source

Re-label a node.

flatten :: m ()Source

Flatten the disjoint set forest for faster lookups.


(MonadUnion l m, MonadTrans t, Monad (t m)) => MonadUnion l (t m) 
MonadUnion l (UnionM l)