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 top
  • LR: from left to right
  • RL: 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 outline
  • point: 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 using fillcolor 2.
  • diagonals
  • rounded

port

A node port is a point where edges can attach to a node3. For any nodes, 8 ports are defined, e, s, w, n, se, sw, ne, nw. They can be used in either of the both ways.

  • Using the attribute of headport or tailport of a edge
  • NODE_NAME:PORT_NAME 4

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, ...];

Footnotes:

2

If not set, the value of color will be adopted.

3

If no port is specified, it is aimed at the node's center and the edge is clipped at the node's boundary.

4

For record-based nodes, it can be NODE_NAME:FIELD_NAME:PORT_NAME.