Graphviz FAQ 2002-09-19

Stephen North, Emden Gansner, John Ellson

Note: This is not a tutorial; to understand this you should know how to use the basic features of the tools and languages involved. Please see the user guides for further information or the page for a partial list of compatible tools and packages.


Q. Where can I see a list of all the attributes that control dot or neato?

See Graph Attributes. There is also information on command-line usage and output formats.

Q. Where can I discuss graphviz?

We run a mailing list.

To subscribe or unsubscribe, visit the graphviz-interest mailman control page. See also the general instructions for mailman.

You can also see the archive.

You may wish to use a Yahoo or Hotmail account if you're concerned about spam. We also run anti-spam filters, and rewrite @ as at to keep verbatim addresses out of the archive.

Please, please, please, do not torment the mailing list with beginner's questions or software build problems. First, check this FAQ and the message archive carefully. Because graphviz software is made available without charge, our resources for routine support are very limited. If you are desperate, please contact ellson, erg, or

Q. I'm trying to make a dot layout larger. How?

Magnification isn't directly supported. We admit this should be fixed. For now you have to adjust individual parameters fontsize, nodesep and ranksep. For example

           digraph G {
                graph [fontsize=24];
                edge  [fontsize=24];
                node  [fontsize=24];
                ranksep = 1.5;
                nodesep = .25;
                edge [style="setlinewidth(3)"];
                a -> b -> c;
If you do this, make sure you are not fighting a conflicting graph size setting, like size="6,6".

If you're using Postscript, you can just scale up the output by manually adding a command such as 2 2 scale where the Postscript environment is set up. Make sure to adjust the BoundingBox too if your tools look at this header.

Q. I'm trying to make a neato layout larger. How?

See above regarding font sizes.

You can generally push nodes further apart by changing len (edge length) attribute. For example, to make it three times the default:

        graph G {
           edge [len=3]
           a -- { b c d }

Q. How can I join or merge certain edge routes?

You can try running dot -Gconcentrate=true or you can introduce your own virtual nodes drawn as tiny circles where you want to split or join edges:

digraph G {
  yourvirtualnode [shape=circle,width=.01,height=.01,label=""];
  a -> yourvirtualnode [arrowhead=none]
  yourvirtualnode -> {b;c}

This only works in graphviz version 1.7 and higher. To make edges between clusters, first set the graph attribute compound=true. Then, you can specify a cluster by name as a logical head or tail to an edge. This will cause the edge joining the two nodes to be clipped to the exterior of the box around the given cluster.

Q. How can I generate graph layouts in PDF?

Use an external converter, for example, dot or neato -Tps | epsf2pdf -o file.pdf
Note that URL tags are respected, to allow clickable PDF objects.

Q. How can I make duplicate nodes?

Make unique nodes with duplicate labels.

      digraph G {
            node001 [label = "A"];
            node002 [label = "A"];
			node001 -> node002;

Q. How can I set a graph or cluster label without its propagating to all sub-clusters?

Set the label at the end of the graph (before the closing brace), after all its contents have been defined. (We admit it seems desirable to define some special syntax for non-inherited attribute settings.)

Q. How can I draw multiple parallel edges in neato?

We're sorry, there's no good answer to this. We're working on it.


Q. How can I create edges between cluster boxes?

This only works in graphviz version 1.7 and higher. To make edges between clusters, first set the graph attribute compound=true. Then, you can specify a cluster by name as a logical head or tail to an edge. This will cause the edge joining the two nodes to be clipped to the exterior of the box around the given cluster.

For example,

      digraph G {
        subgraph cluster_A {
          a -> b;
          a -> c;
        subgraph cluster_B {
          d -> e;
          f -> e;
        a -> e [ ltail=cluster_A,
                 lhead=cluster_B ];
has an edge going from cluster_A to cluster_B. If, instead, you say
        a -> e [ltail=cluster_A];
this gives you an edge from cluster_A to node e. Or you could just specify an lhead attribute. The program warns if a cluster specified as a logical node is not defined. Also, if a cluster is specified as a logical head for an edge, the real head must be contained in the cluster, and the real tail must not be. A similar check is done for logical tails. In these cases, the edge is drawn between the real nodes as usual.

Q. Clusters are hard to see.

Set bgcolor=grey (or some other color) in the cluster.

Q. How can I symmetrize (balance) tree layouts?

When a tree node has an even number of children, it isn't necessarily centered above the two middle ones. If you know the order of the children, a simple hack is to introduce new, invisible middle nodes to re-balance the layout. The connecting edges should also be invisible. For example:

digraph G {
a -> b0;
xb [label="",width=.1,style=invis]
a -> xb [style=invis];
a -> b1;
{rank=same b0 ->  xb -> b1 [style=invis]}
b0 -> c0;
xc [label="",width=.1,style=invis]
b0 -> xc [style=invis];
b0 -> c1;
{rank=same c0 ->  xc -> c1 [style=invis]}
This trick really ought to be build into our solver (and made independent of the order of the children, and available for layouts other than trees, too).

Output features

Q. I can only get 11x17 output.

It's not us! It's probably your printer setup. If you don't believe this, run dot -Tps and looks for the BoundingBox header. The coords are in 1/72ths of an inch.

Q. How do I create special symbols and accents in labels?

The following solution only works with the raster drivers that load Truetype or Type1 fonts! (That means, -Tgif, -Tpng, -Tjpeg, and possibly -Tbmp or -Txbm if enabled). Use UTF8 coding, e.g. ¥ for the Yen currency symbol. Example: graph G { yen [label="¥"] }

You can look up other examples in this handy character set reference .

Q. How do I get font and color changes in record labels or other labels?

There's no easy way right now. We're working on it. Sigh.

Q. In plain format, arrowheads are missing.

It's a bug that may have solidified into a feature by now. A workaround is to set

      edge [dir=none]

Q. How can I print a big graph on multiple pages?

The page attribute, if set, tells graphviz to print the graph as an array of pages of the given size. Thus, the graph

digraph G {
will be emitted as 8.5 by 11 inch pages. When printed, the pages can be tiled to make a drawing of the entire graph. At present, the feature only works with PostScript output.

Alternatively, there are various tools and viewers which will take a large picture and allow you to extract page-size pieces, which can then be printed.

Q. When I have a red edge it shows up as a solid red in PNG and GIF formats, but has a black border when rendered to JPEG.

This is an artifact of JPEG's lossy compression algorithm. JPEG isn't very good for line drawings. PNG is bitmap format of choice. John Ellson wants to deprecate and eventually remove the JPEG driver, but North is reluctant to change anything that people might already rely on.

Q. How can I get custom shapes or images in my graph?

Please see the Shape HowTo for some approaches. There is no easy way to create custom shapes that work with dot/neato, dotty (Unix or MS-Windows) and Grappa (the Java front end), because they don't share any universal back end structure. We're thinking about it.

Q. How can I get some display feature (such as bold lines) in dotty?

In some cases, you can use Grappa or webdot for display instead of dotty. For example, Grappa has generalized polygons (node [shape=polygon]) that dotty lacks.

If the display attribute that you need isn't there already, in dotty, there's probably no easy way to do it except by rolling up your sleeves and hacking the dotty code (a lefty script) that interprets and renders graphical attributes. This is problematic for the same reason as above: there's no universal low-level driver layer shared across all the graphviz tools. We recently added an intermediate rendering language to the layout tools, but the various front ends don't use it yet. This would be a good project for someone who wants to get involved here (along with porting dotty to GTK.)

Q. How can I get rid of the little circles on edges ("edge handles") in dotty?

Edit the file dotty.lefty and change the line that says: 'edgehandles' = 1; to 'edgehandles' = 0; it's around line 110.

Q. I already have all the coordinates for the nodes and edges of my graph and just want to use dot, neato, or dotty to render it. How?

Put the graph with layout attributes into a dot file. Then run neato -s -n2. For example:

neato -s -n2 -Tgif -o file.gif
Note that if an edge does not have a pos attribute defined, neato will perform whatever edge routing it would normally do.

Q. I already have all the coordinates for the nodes, and I want dot or neato to route the edges.

It's not really too convenient to use dot for this. It is possible to use neato for this, running neato -s -n For example:

neato -s -n -Tgif -o file.gif
neato will use the node positions, but use its technique for routing the edges. There are several things to note. First, the neato edge router is different from dot's. Without the built-in top-down bias, it doesn't do as good a job of avoiding edge overlaps and, at present, it doesn't handle multi-edges at all. Second, by default, neato uses straight lines as edges. To get spline routing, you have to specify -Gsplines=true. And this will only work if none of the nodes overlap. Since the input graph supplies fixed node positions, it is the user's task to insure this.

Q. I already have all the coordinates for the nodes and edges of my graph and just want to use dotty to render it. How?

Just run dotty on it. Dotty will use the given pos attributes.

Q. Same as above, but I have only node coords, not edges.

neato -nop -s is some help, but neato doesn't handle parallel edges.

Q. How can I make client-side image maps?

Use the -Tcmap command line option (only version 1.8.9 and beyond!)

Q. Why aren't my server-side maps being recognized? I've checked the HTML!

Make sure that your server has map files enabled. For example, if running apache, check that httpd.conf has a line like the following:

AddHandler imap-file map
and that it is not commented out!

Q. How can I get 3D output?

The graphviz authors have qualms about the gratuitous use of 3D.

Nonetheless, dot -Tvrml generates VRML files. There's no Z coordinate layout - you specify Z coords yourself in the z attribute of nodes, and the Z coordinates of edges are interpolated. If someone contributes a driver for a newer, more useful format (OpenGL Performer scene graphs? Open Scene Graphs? Java3D programs?) we'd like to try it.

neato internally supports layouts in higher dimensions through the dim attribute, e.g. neato -Gdim=7 but there's no way to get the output unless you invoke neato as a library and inspect nodeptr->u.pos[i]. This need some (minor) driver work and a good 7-dimensional viewer. Well, dim=3 ought to be possible.


Q. How can I avoid node overlaps in neato?

neato -Goverlap=false
neato -Goverlap=scale
In the first instance, neato will use a Voronoi diagram-based technique to remove overlaps. In the second, it scales up node positions, but not node shapes, until there are no overlaps. The first technique uses less space; the second preserves symmetries.

Q. How can I avoid node-edge overlaps in neato?

neato -Goverlap=false/scale -Gsplines=true -Gsep=.1

The sep argument is the node-edge separation as a ratio of a node's bounding box. (Don't ask why this isn't just a constant!) Note that this option really slows down neato, so should be used sparingly and only with modest-sized graphs.

Q. Neato runs forever on a certain example.

It could be that your graph is too big, or it could be that neato is cycling. Run neato -v to observe its progress. Neato uses an anti-cycling heuristic, so cycling shouldn't occur, but in real life it still does. (Apparently it keeps falling back into a big, weird potential well.) If your graph is small and the -v output indicates cycling, please submit the graph as a bug report, so we can consider additional heuristics. In addition, there are ways to defeat the cycling by causing neato to use different initial conditions:

neato -Gstart=3
neato -Gstart=rand
or to stop earlier:
neato -Gepsilon=.01
neato -Gmaxiter=500

If it's a large example, the problem is that neato (which is nearly the same algorithm as multidimensional scaling) is at least quadratic in time complexity. The spline router is even worse: O(N^3). So don't run neato -Gsplines=true unless you're willing to pay for it.

Q. Neato doesn't handle multi-edges, and edge label placement is bad.

Difficult problems. We're working on it. If anyone has some general label placement code (e.g. a simulated annealer based on the Marks et al technique in Graphics Gems IV, please get in touch.

Q. Dot runs forever on a certain example.

Try dot -v to observe its progress.

Note that it's possible to make graphs whose layout or even parsing is quadratic in the input size. For example, in dot,

digraph G {
    a -> b -> c -> .... -> x -> y -> z
    a -> z
    b -> z
    c -> z
    /* and so on... */
	x -> z
The total edge length (therefore the layout time) of this as a ranked graph is quadratic in the number of nodes. You probably won't encounter the following, but it is also possible to construct graphs whose parsing takes quadratic time, by appending attributes to nodes and edges after the graph has been loaded. For example:
digraph G {
    /* really big graph goes here... */
    n0 -> n1 -> ... -> n999999999;

    n0 [attr0="whatever"]
    n0 [attr1="something else"]
    /* and so on with many more attributes */
The addition of attr0 touches every node of the graph. Then the addition of attr1 touches every node again, and so on.

Q. Neato has unnecessary edge crossings, or does something bad.

Neato and all similar virtual physical model algorithms rely on heuristic solutions of optimization problems. The better the solution, the longer it takes to find. Unfortunately, it is also possible for these heuristics to get stuck in local minima. Also, it is heavily influenced by the initial position of the nodes. It is quite possible that if you run neato again, but with a different random seed value, or more iterations, you'll get a better layout. For example:

neato -Gstart=5 -Tps -o
neato -Gepsilon=.0000001 -Tps -o
Q. Webdot doesn't work.

We assume you're using Apache and have TCL installed. If you don't, it's probably better to just use the webdot perl script.

To debug webdot, first test whether tclsh can load the Tcldot shared library. Try:

$ tclsh
% load /your/prefix/to/lib/graphviz/
Then test whether it can load the Tcldot package. If you are not installing Tcldot as root (cough), you may need to set TCLLIBPATH to $prefix/lib/graphviz where prefix is the one you set when you ran configure to build graphviz. (If you installed webdot binaries, this doesn't apply because in Linux, binaries are always installed by root, ha, ha.)
$ tclsh
% package require Tcldot
Then test whether webdot runs as a shell command. (With webdot we provide a helper script scaffold.tcl or that sets up an environment like the one Apache provides.) For example
$ scaffold.tcl >out.gif
can't read "LIBTCLDOT": no such variable
    while executing
"file mtime $LIBTCLDOT"
    invoked from within
"set t1 [file mtime $LIBTCLDOT]"
    (file "cgi-bin/webdot" line 67)
    invoked from within
"source cgi-bin/webdot
    (file "scaffold.tcl" line 22)
The above is a strong clue that someone didn't configure webdot properly.

Finally, test whether webdot runs as a cgi-bin program. It may help to examine the cgi-bin environment using a simple cgi-bin perl script like printenv.cgi (this assumes that you have perl5!).

Q. I have "Font not found" errors, or text labels missing in webdot.

For copyright reasons, graphviz doesn't come with its own fonts. On a Windows machine, it knows to search in C:\Windows\Fonts. On a Unix machine, you need to set up a directory that contains Truetype fonts. You can get a copy of some fonts here.

The default DOTFONTPATH is:

#define DEFAULT_FONTPATH "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1"
If your fonts are somewhere else, then you must set that directory in the webdot script, or recompile graphviz with the correct DEFAULT_FONTPATH (or set fontpath="/your/font/directory" in every graph you lay out, but that's pretty clumsy.)

Q. My browser doesn't recognize SVG.

The correct MIME type for svg images is: image/svg+xml (note "+" not "-").

SVG is not built into all browsers; you can get plugins from Adobe for Windows, Linux and some other operating systems. The Amaya browser from W3C is said to have builtin SVG. Batik is an SVG renderer in Java and can be run as a stand-alone program.

For help with embedding SVG in HTML pages, see here.