fsmActions-0.2.0: Data/FsmActions/GraphViz.hs
{- |
GraphViz (dot) rendering using the graphviz library.
-}
-- Copyright (c) 2009 Andy Gimblett - http://www.cs.swan.ac.uk/~csandy/
-- BSD Licence (see http://www.opensource.org/licenses/bsd-license.php)
module Data.FsmActions.GraphViz (
fsmToDot
) where
import Data.GraphViz
import Data.Graph.Inductive.Graph (Graph)
import Data.FsmActions
import Data.FsmActions.FGL
-- | Turn an FSM into a 'Data.GraphViz.DotGraph', trimming any
-- self-loops which aren't sources of nondeterminism.
fsmToDot :: (Ord sy, Show sy) => FSM sy -> DotGraph
fsmToDot = fglDot . flip fsmToFGL Trim
-- Turn an FGL into a DotGraph with labelled edges.
fglDot :: (Ord b, Show b, Graph gr) => gr a b -> DotGraph
fglDot g = graphToDot g [] nodeFn edgeFn
where nodeFn _ = []
edgeFn (_, _, label) = [Label $ Left $ show label]