Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adjust default attributes for dotgraph a bit.

  • Loading branch information...
commit 49ebc4c7b1aec18d768716d8a13f445b9d76d66e 1 parent b7a89b5
@nominolo nominolo authored
Showing with 12 additions and 9 deletions.
  1. +12 −9 examples/WriteDotGraph.hs
View
21 examples/WriteDotGraph.hs
@@ -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"
Please sign in to comment.
Something went wrong with that request. Please try again.