Daniel@0: Daniel@0: Daniel@0: Daniel@0:
Daniel@0:graph | Daniel@0:: | Daniel@0:[ strict ] (graph | digraph) [ ID ] '{' stmt_list '}' | Daniel@0:
stmt_list | Daniel@0:: | Daniel@0:[ stmt [ ';' ] [ stmt_list ] ] | Daniel@0:
stmt | Daniel@0:: | Daniel@0:node_stmt | Daniel@0:
Daniel@0: | | | Daniel@0:edge_stmt | Daniel@0:
Daniel@0: | | | Daniel@0:attr_stmt | Daniel@0:
Daniel@0: | | | Daniel@0:ID '=' ID | Daniel@0:
Daniel@0: | | | Daniel@0:subgraph | Daniel@0:
attr_stmt | Daniel@0:: | Daniel@0:(graph | node | edge) attr_list | Daniel@0:
attr_list | Daniel@0:: | Daniel@0:'[' [ a_list ] ']' [ attr_list ] | Daniel@0:
a_list | Daniel@0:: | Daniel@0:ID [ '=' ID ] [ ',' ] [ a_list ] | Daniel@0:
edge_stmt | Daniel@0:: | Daniel@0:(node_id | subgraph) edgeRHS [ attr_list ] | Daniel@0:
edgeRHS | Daniel@0:: | Daniel@0:edgeop (node_id | subgraph) [ edgeRHS ] | Daniel@0:
node_stmt | Daniel@0:: | Daniel@0:node_id [ attr_list ] | Daniel@0:
node_id | Daniel@0:: | Daniel@0:ID [ port ] | Daniel@0:
port | Daniel@0:: | Daniel@0:':' ID [ ':' compass_pt ] | Daniel@0:
Daniel@0: | | | Daniel@0:':' compass_pt | Daniel@0:
subgraph | Daniel@0:: | Daniel@0:[ subgraph [ ID ] ] '{' stmt_list '}' | Daniel@0:
compass_pt | Daniel@0:: | Daniel@0:(n | ne | e | se | s | sw | w | nw | c | _) | Daniel@0:
Daniel@0: The keywords node, edge, graph, digraph, Daniel@0: subgraph, and strict are case-independent. Daniel@0: Note also that the allowed compass point values are not keywords, so Daniel@0: these strings can be used elsewhere as ordinary identifiers and, conversely, Daniel@0: the parser will actually accept any identifier. Daniel@0:
Daniel@0: An ID is one of the following: Daniel@0:
Daniel@0: Note that in HTML strings, angle Daniel@0: brackets must occur in matched pairs, and unescaped newlines are allowed. Daniel@0: In addition, the content must be legal XML, so that the special XML Daniel@0: escape sequences for ", &, <, and > may be necessary Daniel@0: in order to embed these characters in attribute values or raw text. Daniel@0:Daniel@0: Both quoted strings and HTML strings are scanned as a unit, so Daniel@0: any embedded comments will be treated as part of the strings. Daniel@0:
Daniel@0: An edgeop is -> in directed graphs and -- in Daniel@0: undirected graphs. Daniel@0:
Daniel@0: An a_list clause of the form ID is equivalent to Daniel@0: ID=true. Daniel@0:
Daniel@0: The language supports C++-style comments: /* */ and //. Daniel@0: In addition, a line beginning with a '#' character is considered a line Daniel@0: output from a C preprocessor (e.g., # 34 to indicate line 34 ) and discarded. Daniel@0:
Daniel@0: Semicolons aid readability but are not required except in the rare case Daniel@0: that a named subgraph with no body immediately preceeds an anonymous Daniel@0: subgraph, since the precedence rules cause this sequence to be parsed as Daniel@0: a subgraph with a heading and a body. Daniel@0: Also, any amount of whitespace may be inserted between terminals. Daniel@0:
Daniel@0: As another aid for readability, dot allows single logical lines to Daniel@0: span multiple physical lines using the standard C convention of a Daniel@0: backslash immediately preceding a newline character. In addition, Daniel@0: double-quoted strings can be concatenated using a '+' operator. Daniel@0: As HTML strings can contain newline characters, they do not support the Daniel@0: concatenation operator. Daniel@0:
Daniel@0: Note, in particular, that a subgraph receives the attribute settings of Daniel@0: its parent graph at the time of its definition. This can be useful; for Daniel@0: example, one can assign a font to the root graph and all subgraphs will Daniel@0: also use the font. For some attributes, however, this property is Daniel@0: undesirable. If one attaches a label to the root graph, it is probably Daniel@0: not the desired effect to have the label used by all subgraphs. Rather Daniel@0: than listing the graph attribute at the top of the graph, and the Daniel@0: resetting the attribute as needed in the subgraphs, one can simple defer Daniel@0: the attribute definition if the graph until the appropriate subgraphs Daniel@0: have been defined. Daniel@0:
Daniel@0: If an edge belongs to a cluster, its endpoints belong to that cluster. Daniel@0: Thus, where you put an edge can effect a layout, as clusters are sometimes Daniel@0: laid out recursively. Daniel@0:
Daniel@0: By default, DOT assumes the UTF-8 character encoding. It also accepts Daniel@0: the Latin1 (ISO-8859-1) character set, assuming the input graph uses Daniel@0: the charset attribute to Daniel@0: specify this. For graphs using other Daniel@0: character sets, there are usually programs, such as iconv, which Daniel@0: will translate from one character set to another. Daniel@0:
Daniel@0: Another way to avoid non-ascii characters in labels is to use HTML entities Daniel@0: for special characters. During label evaluation, these entities are Daniel@0: translated into the underlying character. This Daniel@0: Daniel@0: table shows the supported entities, with their Unicode value, a typical Daniel@0: glyph, and the HTML entity name. Thus, to include a lower-case Greek beta Daniel@0: into a string, one can use the ascii sequence β. Daniel@0: In general, one should only use entities that are allowed in the output Daniel@0: character set, and for which there is a glyph in the font. Daniel@0: