import "Visualization/Graphviz" import "MMap" as MMap include "Visualization/Graphviz/Property" data GGraph a e = GGraph Graph (MMap.T a Node) (a -> [Property]) newGGraph :: [Property] -> (a -> [Property]) -> GGraph a e newGGraph properties f = GGraph (newGraph properties) (MMap.create ()) f @private toNode :: GGraph a e -> a -> Node toNode (GGraph graph nodeMap f) r = match MMap.get nodeMap r with Just n -> n Nothing -> do n = newNode graph (f r) MMap.put nodeMap r n n newGEdge :: GGraph a e -> a -> a -> [Property] -> Edge newGEdge graph r1 r2 properties = edge where edge = newEdge (toNode graph r1) (toNode graph r2) properties newGNode :: GGraph a e -> a -> Node newGNode = toNode showGGraph :: GGraph a e -> () showGGraph (GGraph graph _ _) = showGraph graph showGGraphWithAlgorithm :: String -> GGraph a e -> () showGGraphWithAlgorithm algorithm (GGraph graph _ _) = showGraphWithAlgorithm graph algorithm showGGraphWithNamedWindow :: String -> String -> GGraph a e -> () showGGraphWithNamedWindow windowName algorithm (GGraph graph _ _) = showGraphWithNamedWindow windowName graph algorithm