Safe Haskell | None |
---|---|
Language | Haskell2010 |
Monadic interface for creating a disjoint set data structure.
Documentation
Union find monad.
An immutable disjoint set forest.
class Monad m => MonadUnion l m | m -> l where Source #
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 the disjoint set forest for faster lookups.
Instances
(MonadUnion l m, MonadTrans t, Monad (t m)) => MonadUnion l (t m) Source # | |
MonadUnion l (UnionM l) Source # | |