ivan-m / graphviz

Haskell bindings to the Graphviz toolkit
Other
64 stars 24 forks source link

Setting graph name #48

Closed georgefst closed 5 years ago

georgefst commented 5 years ago

As far as I can tell, it isn't currently possible to set the name of the graph. I am hoping to use the graphs output from this library with a tool which unfortunately doesn't aim to support the full .dot specification, and won't parse the files if they don't contain a name.

I am resorting to having to hack the generated file to replace the first line digraph { with digraph foo {.

ShrykeWindgrace commented 5 years ago

When do you need to set the name? E.g. when I define

ghci Data.GraphViz> dg = DotGraph True False (Just (Num 15))  (DotStmts [] [] [] [])

and then run

ghci Data.GraphViz> runGraphviz dg Canon "test.dot"

the output file test.dot has the following contents:

strict graph 15 {
    node [label="\N"];
}

in other words, the graph is named.

georgefst commented 5 years ago

Aha excellent thanks, looks like I just couldn't find the right part of the documentation.

For what it's worth, I'm working with fgl graphs rather than constructing directly. I was expecting this to be influenced by the GraphvizParams passed to graphToDot, but it appears that the graphID field of the result is always Nothing regardless.