I usually describe graphs with graphiz and I enjoy dot2tex which produces the corresponding TikZ code.

To explain an algorithm in a presentation, I need to uncover the nodes and edges of a graph step by step (without changing the layout, of course). I can find some documentation on how to do that when one is writing directly tikz code, for instance Beamer vs. TikZ: uncover nodes step-by-step , but in my case the code is generated automatically from the dot specification. Is it possible to include overlay specification in the dot file?

1 Answer 1


I think that in the dot file you could just include overlay specification for labels. Here is an example of dot file (I call it mygraph.dot):

digraph G {
  1 [texlbl="{\visible<1->{1}}"]; 
  2 [texlbl="{\visible<2->{2}}"];
  3 [texlbl="{\visible<3->{3}}"]; 
  1->2 [label="1/2"];
  2->3 [label="1/2"];
  3->1 [label="1/2"];

Now with the terminal you can create the correspondent TikZ code:

 dot2tex -ftikz mygraph.dot > mygraph.tex

As you know, mygraph.tex is a complete tex document, thus you just have to copy the code of the picture in your presentation. Notice that this applies just for nodes labels, not edge label.

The best way to proceed is:

  • export the dot file in a tex document;
  • edit the picture inserting \pause.

Coming back after one year more or less...

Actually, using overlay specification with GraphViz is perfectly doable by means of the famous Daniel's style visible on from Mindmap tikzpicture in beamer (reveal step by step). Since it is a style, it can be included in the dot file by means of the key style and it does the job for vertices and edges; for the labels, it's possible to exploit the construct {\visible<overlay specification>{label}} or, again the visible on style inside the key lblstyle.

An example:


  visible on/.style={alt=#1{}{invisible}},
  alt/.code args={<#1>#2#3}{%
    \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
  state st/.style={draw,circle,top color=orange!2,bottom color=red!50!orange!50}


\begin{frame}[fragile]{My graph}
\begin{dot2tex}[styleonly,codeonly,circo,options=-s -tmath]
digraph G {
  1 [style="state st,visible on=<2->"]; 
  2 [style="state st,visible on=<3->"]; 
  3 [style="state st,visible on=<4->"];  
  1->2 [label="1/2",style="visible on=<3->",lblstyle="visible on=<3->"];
  2->3 [label="1/2",style="visible on=<4->",lblstyle="visible on=<4->"];
  3->1 [label="1/2",style="visible on=<5->",lblstyle="visible on=<5->"];


The result:

enter image description here

Assuming the file be called anim-graph.tex, it must be compiled as:

pdflatex -shell-escape anim-graph.tex

since the package dot2texi requires to run dot2tex.

  • It seems your solution allows to uncover the text of a node at will and it is already an improvement over what I knew how to do. Still, the nodes remain visible (the circles do not get disappear). Also, do you know how to change the style/color/shape of a node or an edge dynamically?
    – Abdallah
    Apr 8, 2012 at 21:56
  • Sorry for the delay in answering, but I did several trials in my spare time. The conclusion is that, to my best knowledge, is not possible using just dot to change in time styles colors and shapes. As I said in my answer, this can be done editing the tikzpicture after having generated with dot2tex. Apr 13, 2012 at 17:04
  • Is it possible to position the animated graph using absolute coordinates? I tried surrounding the \begin{dot2tex}...\end{dot2tex} part within a \node (g1) at (x,y) { ... }; (and variations) but receive an error: ! Package xkeyval Error: `remember picture' undefined in families `dtt'.
    – user4417
    Mar 9, 2015 at 21:31
  • @user4417: I don't think so. Including all the graph within a node implies nesting tikzpictures, which is usually not recommended (see tex.stackexchange.com/q/51193/13304 and related Q/A). Mar 10, 2015 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.