DOT
Table of Contents
DOT 1 is a language for drawing graphs. It has three main kinds of objects, graph
, node
and edge
. Each object has a variety of attributes. Given a node
or edge
, its attribute(s) can be set as below respectively
NODE_NAME [ATTRIBUTE1=VALUE1, ATTRIBUTE2=VALUE2, ...]; NODE_NAME1 -> NODE_NAME2 [ATTRIBUTE1=VALUE1, ATTRIBUTE2=VALUE2, ...];
And the default values can be specified as below. And they will take effect afterwards.
node [ATTRIBUTE1=VALUE1, ATTRIBUTE2=VALUE2, ...]; edge [ATTRIBUTE1=VALUE1, ATTRIBUTE2=VALUE2, ...];
graph
A graph can be directed or undirected, corresponding to digraph
and graph
, respectively. Within a graph, a subgraph
can be defined as a subset of nodes and edges.
rankdir
TB
: from top to bottom (default value)BT
: from bottom to topLR
: from left to rightRL
: from right to left
size
size="x,y"
ratio
rotate
nodesep
Separation between nodes of the same rank in inches.
ranksep
Separation between ranks in inches.
node
A node is created when its name first appears in the file. A node has following attributes
shape
Node shapes fall into two categories, polygon-based shapes and record-based shapes as below.
Polygon-based shapes
ellipse
(default value)box
circle
plaintext
: a node without any outlinepoint
: a reduced node to display minimal content
Record-based shapes
record
Mrecord
: rounded corners
Record-based nodes represent recursive lists of fields, which are drawn as alternating horizontal and vertical rows of boxes. The recursive structure is determined by attribute label
of the node.
width
The default value is 0.75
height
The default value is 0.5
label
The default label for a node is its name. For multiline labels, any of the following escape symbols will kick off a new line
\n
: center aligned\l
: left aligned\r
: right aligned
The default font is 14pt Times Roman in black color. For other font families, sizes or colors, specify attributes fontname
, fontsize
or fontcolor
, respectively.
style
solid
dashed
dotted
bold
invis
filled
: shade inside the node usingfillcolor
2.diagonals
rounded
edge
A edge is created when nodes are joined by the edge operator
- Directed graph:
->
- Undirected graph:
--
label
Edges are unlabeled by default. As the same as node label, an edge label can also be explicitly set using the label
attribute. Specially, an edge can be given additional labels with attributes headlabel
and taillabel
. For edge labels, the font can be customized using the attributes labelfontname
, labelfontsize
and labelfontcolor
.
dir
This attribute is used to set arrowheads, which can be
forward
(default value)back
both
none
headport/tailport
NODE_NAME1 -> NODE_NAME2 [headport/tailport=e/w/n/s/se/sw/ne/nw, OTHER_ATTRIBUTE=VALUE, ...];