Graphviz

Table of Contents

Visualize structural information as diagrams of graphs and networks.

Supports unicode.

1. CLI

1.1. Layout Engine

The layout engine of a graph dramatically affects the shape of a graph.

There are separate command for each layout engine, but it can be overrided by -K option which then overrided by graph attribute: graph [layout = ENGINE].

  • dot the default hierarchical layout
  • neato spring model layout
  • fdp force-directed placement
  • sfdp scalable force-directed placement
  • circo circular layout
  • twopi radial layout
  • osage cluster graph
  • patchwork squarified treemap layout

1.1.1. Layout Options

  • -N<option> node option
  • -E<option> edge option
  • -G<option> graph option
  • -A<option> "any" option
  • -K<layout> select layout engine
  • -T<format>[:<renderer>[:<formatter>]] select output format
  • -T<layout> select output format
  • -l<library> include library
  • -o<outfile> set output file name
  • -o<outfile> set output file name, -O to automatically generate the file name.

1.2. Tools

  • acylic remove cycles
  • dijkstra single-source distance filter
  • gc count graph components
  • nop pretty-print graph file

2. DOT Language

graph		:	[ strict ] (graph | digraph) [ ID ] '{' stmt_list '}'
stmt_list	:	[ stmt [ ';' ] stmt_list ]
stmt		:	node_stmt | edge_stmt | attr_stmt | ID '=' ID | subgraph
attr_stmt	:	(graph | node | edge) attr_list
attr_list	:	'[' [ a_list ] ']' [ attr_list ]
a_list	:	ID '=' ID [ (';' | ',') ] [ a_list ]
edge_stmt	:	(node_id | subgraph) edgeRHS [ attr_list ]
edgeRHS	:	edgeop (node_id | subgraph) [ edgeRHS ]
node_stmt	:	node_id [ attr_list ]
node_id	:	ID [ port ]
port		:	':' ID [ ':' compass_pt ] | ':' compass_pt
subgraph	:	[ subgraph [ ID ] ] '{' stmt_list '}'
compass_pt	:	n | ne | e | se | s | sw | w | nw | c | _
  • Attribute statement (attr_stmt) sets attribute to every graph, node, or edge.
  • Edge statement draw and modify a single edge.
  • Node statement modify a single edge.

The default background color is white, and the default fontcolor is not set, which make it work poorly with dark mode that usually sets the fontcolor to white. The solution is change any of the color:

  • graph [bgcolor = "transparent"]
  • node [fontcolor = "black"]
  • <node_id> [fontcolor = "black"]

3. Custom Layout Plugin

Layout engine is written in C.

4. Examples

5. References

Author: Jeemin Kim

Created: 2026-07-12 Sun 14:28