Permalink
Browse files

Adjust default attributes for dotgraph a bit.

  • Loading branch information...
1 parent b7a89b5 commit 49ebc4c7b1aec18d768716d8a13f445b9d76d66e @nominolo nominolo committed Nov 4, 2008
Showing with 12 additions and 9 deletions.
  1. +12 −9 examples/WriteDotGraph.hs
View
@@ -1,27 +1,30 @@
module WriteDotGraph (writeDotGraph) where
-import Data.List (nub)
+import Data.List (nub, intercalate)
-writeDotGraph :: (Show node, Eq node) => [(node, node)] -> String
+writeDotGraph :: (Show node, Eq node) => [(node, [String], node)] -> String
writeDotGraph edges =
unlines (
[header
,graphDefaultAtribs
,nodeDefaultAtribs
- ,edgeDefaultAtribs]
+ ,edgeDefaultAtribs
+ ,otherDefaults]
++ map makeNode nodes
++ map makeEdge edges
++ [footer]
)
- where nodes = nub $ concat [ [a,b] | (a,b) <- edges ]
+ where nodes = nub $ concat [ [a,b] | (a,_,b) <- edges ]
makeNode name = "\t" ++ show (show name) ++ " [];"
- makeEdge (node1, node2) =
- "\t" ++ show (show node1) ++ " -> " ++ show (show node2) ++ "[];"
+ makeEdge (node1, attribs, node2) =
+ "\t" ++ show (show node1) ++ " -> " ++ show (show node2)
+ ++ "[" ++ intercalate "," attribs ++ "];"
header = "digraph g {"
footer = "}"
-graphDefaultAtribs = "\tgraph [fontsize=14, fontcolor=black, color=black];"
-nodeDefaultAtribs = "\tnode [label=\"\\N\", width=\"0.75\", shape=ellipse];"
-edgeDefaultAtribs = "\tedge [fontsize=10];"
+graphDefaultAtribs = "\tgraph [fontsize=7, fontcolor=black, color=black];"
+nodeDefaultAtribs = "\tnode [label=\"\\N\", width=\"0.3\", shape=plaintext];"
+edgeDefaultAtribs = "\tedge [fontsize=5,colorscheme=rdylgn11];"
+otherDefaults = "\tranksep=5;\n\tratio=auto"

0 comments on commit 49ebc4c

Please sign in to comment.