Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype MUnionFind s = MUnionFind (MVector s MUFNode)
- type IOUnionFind = MUnionFind RealWorld
- type STUnionFind s = MUnionFind s
- data MUFNode
- newMUF :: PrimMonad m => Int -> m (MUnionFind (PrimState m))
- rootMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> m Int
- sameMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m Bool
- _unwrapMUFRoot :: MUFNode -> Int
- unifyMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m Bool
- unifyMUF_ :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m ()
- sizeMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> m Int
- clearMUF :: PrimMonad m => MUnionFind (PrimState m) -> m ()
- groupRootsMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> m (Vector Int)
- groupsMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> m (IntMap [Int])
Documentation
newtype MUnionFind s #
Dense, mutable Union-Find tree (originally by `@pel`)
>>>
stree <- newMUF 3
>>>
sameMUF stree 0 2
False>>>
unifyMUF stree 0 2
True>>>
sameMUF stree 0 2
True>>>
unifyMUF stree 0 2
False
See also
MUnionFind (MVector s MUFNode) |
type IOUnionFind = MUnionFind RealWorld #
type STUnionFind s = MUnionFind s #
MUFChild parent | MUFRoot size
.
Instances
newMUF :: PrimMonad m => Int -> m (MUnionFind (PrimState m)) #
\(O(N)\) Creates a new Union-Find tree of the given size.
rootMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> m Int #
\(O(\alpha(N))\) Returns the root node index.
sameMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m Bool #
\(O(\alpha(N))\) Checks if the two nodes are under the same root.
_unwrapMUFRoot :: MUFNode -> Int #
Just an internal helper.
unifyMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m Bool #
\(O(1)\) Unifies two nodes. Returns True
when thry're newly unified.
unifyMUF_ :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> Int -> m () #
\(O(1)\)
sizeMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> Int -> m Int #
\(O(\alpha(N))\) Returns the size of the a node, starting with `1`.
clearMUF :: PrimMonad m => MUnionFind (PrimState m) -> m () #
\(O(N)\)
groupRootsMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> m (Vector Int) #
\(O(N \alpha(N))\) Returns all root vertices.
groupsMUF :: (HasCallStack, PrimMonad m) => MUnionFind (PrimState m) -> m (IntMap [Int]) #
\(O(N W)\) Collects groups. Returns a list of (root, component)
. Too slow?