haskus-utils-0.8.0.0: Haskus utility modules

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.STM.TGraph

Description

Transactionnal graph

Synopsis

Documentation

deepFirst :: (Monad m, Ord a) => (a -> m ()) -> (a -> m ()) -> (a -> m [a]) -> [a] -> m () Source #

Deep-first graph traversal

before is executed when the node is entered after is executed when the node is leaved children gets node's children

breadthFirst :: (Monad m, Ord a) => (a -> m Bool) -> (a -> m [a]) -> [a] -> m () Source #

Breadth-first graph traversal

visit is executed when the node is entered. If False is returned, the traversal ends children gets node's children

data TNode a r Source #

A node contains a value and two lists of incoming/outgoing edges

Constructors

TNode 

Fields

singleton :: a -> STM (TNode a r) Source #

Create a graph node

linkTo :: TNode a r -> r -> TNode a r -> STM () Source #

Link two nodes together