"Sometimes the answer is 'no'."
So, no. GraphViz lacks the notion of "named styles" seen in word processors like Microsoft Word and LibreOffice, and lacks the style "class" notion from HTML and CSS. Its formatting attributes are more primitive and, in many cases, must be explicitly stated.
You can set some defaults, as in its finite state machine example:
node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8;
node [shape = circle];
Here you get defaulting to the shape of a circle (the last shape defined), with explicit calling out of a handful of nodes that are previously declared under a previous default (doublecircle
). This is a convenience for some designs, but it requires a good degree of preplanning (e.g. of the order items are declared). You can sometimes use the subgraph
feature to help organize defaults by group, as this Stack Overflow answer shows.
But defaults are a small comfort to those of us used to expressive, simple type mechanisms. A look at the rest of the documentation confirms that, while you can use some HTML-styling elements for text, e.g., they are restricted to HTML tags such as <b>
and <i>
. This is primitive HTML styling circa 2001, prior to the spread of quality CSS.
Don't be fooled by the stylesheet
attribute, either; it's only for SVG output, and is disappointingly much less general and valuable than it first seems.
So, long story short, "no." GraphViz has no built-in reusable style elements. If you want that, you will have to build that separately using a program, a macro-preproessor, or the like. Sorry!