/usr/share/doc/graphviz/html/info/lang.html is in graphviz-doc 2.26.3-10ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<!--
This is a generated document. Do not edit.
-->
<HTML VERSION="2.0">
<HEAD>
<TITLE>The DOT Language</TITLE>
</HEAD>
<BODY BGCOLOR=white>
<A NAME="top"></A>
<H1 ALIGN=CENTER>The DOT Language</H1>
<HR>
The following is an abstract grammar defining the DOT language.
Terminals are shown in bold font and nonterminals in italics.
Literal characters are given in single quotes.
Parentheses ( and ) indicate grouping when needed.
Square brackets [ and ] enclose optional items.
Vertical bars | separate alternatives.
<TABLE>
<TR>
<TD ALIGN=RIGHT><I>graph</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>[ <B>strict</B> ] (<B>graph</B> | <B>digraph</B>) [ <I>ID</I> ] <B>'{'</B> <I>stmt_list</I> <B>'}'</B></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>stmt_list</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>[ <I>stmt</I> [ <B>';'</B> ] [ <I>stmt_list</I> ] ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>stmt</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><I>node_stmt</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT></TD>
<TD ALIGN=LEFT>|</TD>
<TD ALIGN=LEFT><I>edge_stmt</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT></TD>
<TD ALIGN=LEFT>|</TD>
<TD ALIGN=LEFT><I>attr_stmt</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT></TD>
<TD ALIGN=LEFT>|</TD>
<TD ALIGN=LEFT><I>ID</I> <B>'='</B> <I>ID</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT></TD>
<TD ALIGN=LEFT>|</TD>
<TD ALIGN=LEFT><I>subgraph</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>attr_stmt</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>(<B>graph</B> | <B>node</B> | <B>edge</B>) <I>attr_list</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>attr_list</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><B>'['</B> [ <I>a_list</I> ] <B>']'</B> [ <I>attr_list</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>a_list</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><I>ID</I> [ <B>'='</B> <I>ID</I> ] [ <B>','</B> ] [ <I>a_list</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>edge_stmt</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>(<I>node_id</I> | <I>subgraph</I>) <I>edgeRHS</I> [ <I>attr_list</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>edgeRHS</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><I>edgeop</I> (<I>node_id</I> | <I>subgraph</I>) [ <I>edgeRHS</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>node_stmt</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><I>node_id</I> [ <I>attr_list</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>node_id</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><I>ID</I> [ <I>port</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>port</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT><B>':'</B> <I>ID</I> [ <B>':'</B> <I>compass_pt</I> ]</TD>
</TR>
<TR>
<TD ALIGN=RIGHT></TD>
<TD ALIGN=LEFT>|</TD>
<TD ALIGN=LEFT><B>':'</B> <I>compass_pt</I></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>subgraph</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>[ <B>subgraph</B> [ <I>ID</I> ] ] <B>'{'</B> <I>stmt_list</I> <B>'}'</B></TD>
</TR>
<TR>
<TD ALIGN=RIGHT><I>compass_pt</I></TD>
<TD ALIGN=LEFT>:</TD>
<TD ALIGN=LEFT>(<B>n</B> | <B>ne</B> | <B>e</B> | <B>se</B> | <B>s</B> | <B>sw</B> | <B>w</B> | <B>nw</B> | <B>c</B> | <B>_</B>)</TD>
</TR>
</TABLE>
<P>
The keywords <B>node</B>, <B>edge</B>, <B>graph</B>, <B>digraph</B>,
<B>subgraph</B>, and <B>strict</B> are case-independent.
Note also that the allowed compass point values are not keywords, so
these strings can be used elsewhere as ordinary identifiers and, conversely,
the parser will actually accept any identifier.
<P>
An <I>ID</I> is one of the following:
<MENU>
<LI> Any string of alphabetic (<TT>[a-zA-Z\200-\377]</TT>) characters, underscores (<TT>'_'</TT>) or
digits (<TT>[0-9]</TT>), not beginning with a digit;
<LI> a numeral [<tt>-</tt>]<sup>?</sup>(<tt>.</tt>[<tt>0</tt>-<tt>9</tt>]<sup>+</sup> | [<tt>0</tt>-<tt>9</tt>]<sup>+</sup>(<tt>.</tt>[<tt>0</tt>-<tt>9</tt>]<sup>*</sup>)<sup>?</sup> );
<LI> any double-quoted string ("...") possibly containing escaped
quotes (\")<SUP>1</SUP>;
<LI> an <A NAME=html>HTML string</A> (<...>).
</MENU>
An ID is just a string; the lack of quote characters in the first two
forms is just for simplicity. There is no semantic difference between
<TT>abc_2</TT> and <TT>"abc_2"</TT>, or between <TT>2.34</TT> and
<TT>"2.34"</TT>. Obviously, to use a keyword as an ID, it must be quoted.
Note that, in HTML strings, angle
brackets must occur in matched pairs, and unescaped newlines are allowed.
In addition, the content must be legal XML, so that the special XML
escape sequences for ", &, <, and > may be necessary
in order to embed these characters in attribute values or raw text.
<P>
Both quoted strings and HTML strings are scanned as a unit, so
any embedded comments will be treated as part of the strings.
<P>
An <I>edgeop</I> is <TT>-></TT> in directed graphs and <TT>--</TT> in
undirected graphs.
<P>
An <I>a_list</I> clause of the form <I>ID</I> is equivalent to
<I>ID</I><TT>=true</TT>.
<P>
The language supports C++-style comments: <TT>/* */</TT> and <TT>//</TT>.
In addition, a line beginning with a '#' character is considered a line
output from a C preprocessor (e.g., # 34 to indicate line 34 ) and discarded.
<P>
Semicolons aid readability but are not required except in the rare case
that a named subgraph with no body immediately preceeds an anonymous
subgraph, since the precedence rules cause this sequence to be parsed as
a subgraph with a heading and a body.
Also, any amount of whitespace may be inserted between terminals.
<P>
As another aid for readability, dot allows single logical lines to
span multiple physical lines using the standard C convention of a
backslash immediately preceding a newline character. In addition,
double-quoted strings can be concatenated using a '+' operator.
As HTML strings can contain newline characters, they do not support the
concatenation operator.
<H2>Subgraphs and Clusters</H2>
Subgraphs play three roles in Graphviz. First, a subgraph can be used to
represent graph structure, indicating that certain nodes and edges should
be grouped together. This is the usual role for subgraphs
and typically specifies semantic information about the graph components.
<P>
In the second role, a subgraph can provide a context for setting attributes.
For example, a subgraph could specify that blue
is the default color for all nodes defined in it.
In the context of
graph drawing, a more interesting example is:
<PRE>
subgraph {
rank = same; A; B; C;
}
</PRE>
This (anonymous) subgraph specifies that the nodes A, B and C
should all be placed on the same rank if drawn using dot.
<P>
The third role for subgraphs directly involves how the graph
will be laid out by certain layout engines. If the name of
the subgraph begins with <TT>cluster</TT>, Graphviz notes the subgraph as
a special <I>cluster</I> subgraph. If supported, the layout engine will
do the layout so that the nodes belonging to the cluster are drawn together,
with the entire drawing of the cluster contained within a bounding rectangle.
Note that, for good and bad, cluster subgraphs are not part of the
DOT language, but solely a syntactic convention adhered to by
certain of the layout engines.
<H2>Lexical and Semantic Notes</H2>
If a default attribute is
defined using a <B>node</B>, <B>edge</B>, or <B>graph</B> statement,
or by an attribute assignment not attached to a node or edge, any object of the
appropriate type defined afterwards will inherit this attribute value.
This holds until the default attribute is set to a new value, from which
point the new value is used. Objects defined before a default attribute
is set will have an empty string value attached to the attribute once
the default attribute definition is made.
<P>
Note, in particular, that a subgraph receives the attribute settings of
its parent graph at the time of its definition. This can be useful; for
example, one can assign a font to the root graph and all subgraphs will
also use the font. For some attributes, however, this property is
undesirable. If one attaches a label to the root graph, it is probably
not the desired effect to have the label used by all subgraphs. Rather
than listing the graph attribute at the top of the graph, and the
resetting the attribute as needed in the subgraphs, one can simple defer
the attribute definition if the graph until the appropriate subgraphs
have been defined.
<P>
If an edge belongs to a cluster, its endpoints belong to that cluster.
Thus, where you put an edge can effect a layout, as clusters are sometimes
laid out recursively.
<P>
There are certain restrictions on subgraphs and clusters. First, at
present, the names of a graph and it subgraphs share the same namespace.
Thus, each subgraph must have a unique name. Second, although nodes
can belong to any number of subgraphs, it is assumed clusters form
a strict hierarchy when viewed as subsets of nodes and edges.
<H2>Character encodings</H2>
The DOT language assumes at least the ascii character set.
Quoted strings, both ordinary and HTML-like, may contain non-ascii characters.
In most cases, these strings are uninterpreted: they simply serve as
unique identifiers or values passed through untouched. Labels, however,
are meant to be displayed, which requires that the software be able to
compute the size of the text and determine the appropriate glyphs.
For this, it needs to know what character encoding is used.
<P>
By default, DOT assumes the UTF-8 character encoding. It also accepts
the Latin1 (ISO-8859-1) character set, assuming the input graph uses
the <B><A HREF=attrs.html#a:charset>charset</A></B> attribute to
specify this. For graphs using other
character sets, there are usually programs, such as <TT>iconv</TT>, which
will translate from one character set to another.
<P>
Another way to avoid non-ascii characters in labels is to use HTML entities
for special characters. During label evaluation, these entities are
translated into the underlying character. This
<a HREF="http://www.graphviz.org/doc/char.html">
table</a> shows the supported entities, with their Unicode value, a typical
glyph, and the HTML entity name. Thus, to include a lower-case Greek beta
into a string, one can use the ascii sequence <TT>&beta;</TT>.
In general, one should only use entities that are allowed in the output
character set, and for which there is a glyph in the font.
<HR>
<OL TYPE="1">
<LI> In quoted strings in DOT, the only escaped character is double-quote
("). That is, in quoted strings, the dyad \" is converted to "; all other
characters are left unchanged. In particular, \\ remains \\. Layout
engines may apply additional escape sequences.
</OL>
</BODY>
</HTML>
|