[Haskell-cafe] Canonical Graphviz code

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Jul 6 18:15:03 EDT 2010


"Kevin Quick" <quick at sparq.org> writes:

> On Mon, 05 Jul 2010 19:26:34 -0700, Ivan Miljenovic
> <ivan.miljenovic at gmail.com> wrote:
>
>> Graphviz (http://graphviz.org/) has the option to convert provided
> Dot
>> code for visualising a graph into a canonical form.  For example,
> take
>> the sample Dot code:
> [snip]
>> I've recently thought up a way that I can duplicate this
> functionality
>> (in terms of what it does, not necessarily the actual output) in my
>> graphviz library (http://hackage.haskell.org/package/graphviz),
>> however I'm not sure how closely to follow what Graphviz does.
>
> There doesn't seem to be a clear definition of "canon" output is, and
> the implication in the documentation is that this mode might better
> have been named "pprint" (thus my hesitance to refer to it as
> "canonical form").  Based on this, I'd suggest that you don't need
> strict adherence to graphviz.

Even better; after sending that email out yesterday I wrote a Dot-graph
by hand and it had some very weird characteristics; try to guess what
this looks like:

,----
| digraph {
|         a;
|         subgraph cluster {
|                  a -> b;
|         }
| }
`----

Note that it isn't the location of the definition of `a' that's the
problem; it's the definition of the location of the edge: edges should
be defined in the innermost context where _both_ nodes are.

As such, I probably won't be implementing the canonical form stuff any
time soon in graphviz, and might need to examine Graphviz's source code
to compare it and ensure that it's at least similar :s

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list