I have a simple directed graph in Graphviz with two kinds of nodes and edges. Each kind has it's own color. My problem is, that I would like to keep how the graph is drawn, but just change the colors. However, when I swap the node names within the two node definitions, the graph changes its layout.
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen] 3 "4-5" 7 "8-9" 10 18 19
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = grey] 11 12 "13-14"
Is there a way to force it to one static layout?
The order in which the nodes are defined does have an impact on the layout.
If you want to keep the layout and change only the colors of the nodes, then you'll need to keep the order of (first) appearance of the nodes and only change their fillcolor
attribute.
For example:
digraph g {
node [shape = circle, width = 0.95, fixedsize = true, style = filled, fillcolor = palegreen];
3;
"4-5";
7;
"8-9";
10 [fillcolor = grey];
18;
19;
// new default fillcolor
node [fillcolor = grey];
11;
12 [fillcolor = palegreen];
"13-14";
}
Resulting in
You can specify the default attributes using the node [fillcolor = grey]
instruction, and override the default values on a specific node if needed (12 [fillcolor = palegreen]
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With