Search notes:

Graphviz: node

The shape of a node can be specified with the shape attribute.
There are three main types of nodes:

Default attributes

The default attributes for nodes are shape=ellipse, width=.75, height=.5 label="\N":
The default value of "\N" for a node's label attribute causes the label (that is: the text within the node) to be the name of the node. (See the escString type.)
digraph DefAttr {

   N1
   N2 [ shape=ellipse, width=.75, height=.5 label="\N" ]

}
Github repository about-Graphviz, path: /elems/node/default-attributes.dot

color attribute

The color attribute only affects the color of the border around the node, not the color of the label within the node:
digraph {

   node  [ shape = box   ]

   red   [ color = red   ]
   blue  [ color = blue  ]
   green [ color = green ]
   none  [               ]

}
Github repository about-Graphviz, path: /elems/node/color.dot
In order to modify the color of the lable, the fontcolor attribute must be used.
See also attributes that are related to colors.

Filled nodes

In order to produce a node that is filled with a (background-)color, it needs to have the two attributes
digraph X {

   node [ shape = box ]

   node_1 [ fillcolor=bisque  style=filled label="style=filled and fillcolor" ]
   node_2 [   bgcolor=red     style=filled label="style=filled and bgcolor"   ] // bgcolor is not respected, color will be grey
   node_3 [ fillcolor=bisque               label="no style but fillcolor"     ]
   node_4 [   bgcolor=red                  label="no style but bgcolor"       ]

   node_1 -> node_2 -> node_3 -> node_4 [ style=invis ]
}
Github repository about-Graphviz, path: /elems/node/filled.dot

Size of a node

shape=plain is shorthand for shape=none width=0 height=0 margin=0. This enforces that the size of the node is determined by its label.

Ranking nodes

By default, nodes are ranked by the edges they're connected with. This ranking can be turned off by setting an edge's attribute constraint to false.

See also

Graphviz elements

Index