Boost logo

Boost :

From: Ronald Garcia (garcia_at_[hidden])
Date: 2007-06-21 11:36:09


On Jun 20, 2007, at 4:44 PM, Marshall Clow wrote:

>>
> How do I keep "global settings" when reading and writing a graphviz
> file?
>
> For example, consider the following file:
>
> digraph G {
> node [ color=blue ];
> rankDir=LR
>
> a0 [ label = "//depot/path/to/file_1#4" ];
> a1 [ label = "//depot/path/to/file_2#9" ];
>
> a0 -> a1 [ color=gray ];
> }
>
> when read and written (with no changes) becomes:
>
> digraph G {
> a0 [ color="blue" , label = "//depot/path/to/file_1#4" ];
> a1 [ color="blue" , label = "//depot/path/to/file_2#9" ];
> a0 -> a1 [ color="gray" ];
> }
>
> As you can see, the global property "node [ color=blue ];" has been
> set in each individual node,
> and the "rankdir=LR" has been completely lost. The first one
> doesn't change how the graph gets rendered, but the second one
> certainly does.
>
> Any way to preserve either of these?

Because of the way the graphviz language works, the node and edge
settings are associated directly with the nodes and edges of the
graph. Node and edge settings are only global until another setting
is put in place. It's legal to write:

digraph G {
   node [color=blue];
   a0
   a1
   node [color=gray];
   a2
}

and that is semantically equivalent to

digraph G {
   a0 [color=blue]
   a1 [color=blue]
   a2 [color=gray];
}

As for the graph properties, the reader in CVS supports graph
properties. For an example use, look at libs/boost/graph/test/
graphviz_test.cpp.

Cheers,
ron


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk