The same nodes, different colors in Graphviz

I have a simple directed graph in Graphviz with two types of nodes and edges. Each species has its own color. My problem is that I would like to keep the drawing schedule, but just change the colors. However, when I replace the node names in 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 get it to create one static layout?

+4
source share
1 answer

the order in which nodes are defined affects layout.

If you want to save the layout and change only the colors of the nodes, you need to save the order of the (first) appearance of the nodes and change their fillcolor attribute.

For instance:

 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"; } 

Result

fillcolor nodes

You can specify default attributes using the node [fillcolor = grey] command and override the default values on a particular node if necessary ( 12 [fillcolor = palegreen] ).

+8
source

All Articles