Does the DOT language support variables / aliases?
graphviz
Solution
You can define default values in order to avoid repetition:
digraph g{
node[fillcolor=red];
barn;
house;
...
node[fillcolor=green];
farm;
...
edge[color=red];
barn -> house;
edge[color=green];
barn --> farm;
house --> farm;
}
Real variables are not supported.
A more complex workaround would be to use `gvpr` - graph pattern scanning and processing language.
`gvpr` reads and outputs graph and allows to add and modify graphs, nodes and attributes.
You could for example store custom information in the `comment` attribute and have your script act based on the content of this attribute.
This and this SO answer contain examples of `gvpr` scripts.
Problem
I'm trying to print out a directed graph, and I keep changing various node attributes such as color and shape. Is there some way to use a variable which is defined once and used for multiple nodes? Ideally I'd like something like this: ``` digraph g { building_color = "red" land_color = "green" farm [ fillcolor=land_color] barn [ fillcolor=building_color] house [ fillcolor=building_color] } ``` So I can change building color once without having to go to each node. Is this possible?