improve output
This commit is contained in:
parent
926df3d91e
commit
30869187f0
1 changed files with 7 additions and 6 deletions
13
Dot.hs
13
Dot.hs
|
@ -9,7 +9,7 @@ module Dot where -- import qualified
|
||||||
|
|
||||||
{- generates a graph description from a list of lines -}
|
{- generates a graph description from a list of lines -}
|
||||||
graph :: [String] -> String
|
graph :: [String] -> String
|
||||||
graph s = unlines $ [header] ++ map formatLine s ++ [footer]
|
graph s = unlines $ [header] ++ map indent s ++ [footer]
|
||||||
where
|
where
|
||||||
header = "digraph map {"
|
header = "digraph map {"
|
||||||
footer= "}"
|
footer= "}"
|
||||||
|
@ -20,7 +20,7 @@ graphNode nodeid desc = label desc $ quote nodeid
|
||||||
|
|
||||||
{- an edge between two nodes -}
|
{- an edge between two nodes -}
|
||||||
graphEdge :: String -> String -> Maybe String -> String
|
graphEdge :: String -> String -> Maybe String -> String
|
||||||
graphEdge fromid toid desc =
|
graphEdge fromid toid desc = indent $
|
||||||
case desc of
|
case desc of
|
||||||
Nothing -> edge
|
Nothing -> edge
|
||||||
Just d -> label d edge
|
Just d -> label d edge
|
||||||
|
@ -43,14 +43,15 @@ fillColor color s = attr "fillcolor" color $ attr "style" "filled" $ s
|
||||||
{- apply to graphNode to put the node in a labeled box -}
|
{- apply to graphNode to put the node in a labeled box -}
|
||||||
subGraph :: String -> String -> String -> String
|
subGraph :: String -> String -> String -> String
|
||||||
subGraph subid l s =
|
subGraph subid l s =
|
||||||
"subgraph " ++ name ++ "{\n\t" ++ setlabel ++ "\n\t\t" ++ s ++ "\n\t}"
|
"subgraph " ++ name ++ " {\n" ++ ii setlabel ++ ii s ++ indent "}"
|
||||||
where
|
where
|
||||||
-- the "cluster_" makes dot draw a box
|
-- the "cluster_" makes dot draw a box
|
||||||
name = quote ("cluster_" ++ subid)
|
name = quote ("cluster_" ++ subid)
|
||||||
setlabel = formatLine $ "label=" ++ quote l
|
setlabel = "label=" ++ quote l
|
||||||
|
ii x = (indent $ indent x) ++ "\n"
|
||||||
|
|
||||||
formatLine :: String -> String
|
indent ::String -> String
|
||||||
formatLine s = "\t" ++ s ++ ";"
|
indent s = "\t" ++ s
|
||||||
|
|
||||||
quote :: String -> String
|
quote :: String -> String
|
||||||
quote s = "\"" ++ s' ++ "\""
|
quote s = "\"" ++ s' ++ "\""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue