
At 11:36 AM -0400 6/21/07, Ronald Garcia wrote:
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]; }
Ok. That's what I figured - it is unfortunate, but I can live with that.
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.
Do you mean boost/libs/graph/test/graphviz_test.cpp? I looked in the file, and the only graph properties that I can see are the types of the node and edge properties. Am I missing something? I have two goals here, one short term, and one long term. The short term goal is to read and write a Graphviz file successfully (which I am mostly doing, thanks in large part to your answers and bug fixes!), and the long term one is to understand what the graph library is doing so that I can use it better. The short term problem that I am trying to solve is that when I read and then write a Graphviz file, I don't get all the information back. In particular, I get results like this: Input: digraph G { rankDir=LR a0 [ label = "//depot/path/to/file_1#4" ]; a1 [ label = "//depot/path/to/file_2#9" ]; a0 -> a1 [ color=gray ]; } Output: digraph G { a0 [ label = "//depot/path/to/file_1#4" ]; a1 [ label = "//depot/path/to/file_2#9" ]; a0 -> a1 [ color="gray" ]; } The line: rankDir=LR has been lost, and Graphviz renders the file quite differently in the absence of this line. I called this a "graph property" in my earlier email, which may not have been the right term. Is there an easy way to convince the Graphviz reader and writer to preserve that command? -- -- Marshall Marshall Clow Idio Software <mailto:marshall@idio.com> It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.