% Examples from the dot2tex documentation
\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes,automata,snakes,backgrounds,arrows}

\usepackage[pgf,outputdir={docgraphs/}]{dot2texi}

\usepackage[active,tightpage]{preview}

\begin{document}


\begin{preview}%
\begin{tabular}{cc}%
\begin{dot2tex}[mathmode,pgf]
digraph G {
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
&\begin{dot2tex}[pgf]
digraph G {
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
\end{tabular}%
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf]
digraph G {
    a_1 [texlbl="$\frac{\gamma}{x^2}$"];
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf]
digraph G {
    a_1 [texlbl="$\frac{\gamma}{2x^2+y^3}$"];
    a_1 -> a_2 -> a_3 -> a_1
    node [texmode="math"];
    a_1 -> b_1 -> b_2 -> a_3;
    b_1 [label="\\frac{\\gamma}{x^2}"];
    node [texmode="verbatim"]
    b_4 [label="\\beta"]
    a_3 -> b_4 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf,autosize]
digraph G {
    a_1 [texlbl="$\frac{\gamma}{2x^2+y^3}$"];
    a_1 -> a_2 -> a_3 -> a_1
    node [texmode="math"];
    a_1 -> b_1 -> b_2 -> a_3;
    b_1 [label="\\frac{\\gamma}{x^2}"];
    node [texmode="verbatim"]
    b_4 [label="\\beta"]
    a_3 -> b_4 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf]
digraph G {
    node0 [label="{left|right}", shape=record];
    node1 [shape=rectangle, label="node 1"];
    node0 -> node1;
    rankdir=LR;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf,options=--valignmode dot]
digraph G {
    node0 [label="{left|right}", shape=record];
    node1 [shape=rectangle, label="node 1"];
    node0 -> node1;
    rankdir=LR;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf]
digraph G {
    d2toptions="--valignmode=dot";
    d2tgraphstyle="anchor=base";
    node0 [label="{left|right}", shape=record];
    node1 [shape=rectangle, label="node 1"];
    node0 -> node1;
    rankdir=LR;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[pgf]
digraph G {
    d2toptions="--valignmode=dot";
    d2tgraphstyle="anchor=base";
    node [fontsize=10];
    node0 [label="{left|right}", shape=record];
    node1 [shape=rectangle, label="node 1"];
    node0 -> node1;
    rankdir=LR;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[mathmode]
digraph G {
    node [shape=circle];
    a_1 [texlbl="$x^2+\frac{\sin y}{y^2+\cos \beta}+\gamma_3$"];
    a_1 -> a_2 [label=" ", texlbl="$x_1+x_3^2+z+c+v~~$"];
    a_2 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[mathmode,autosize]
digraph G {
    node [shape=circle];
    a_1 [texlbl="$x^2+\frac{\sin y}{y^2+\cos \beta}+\gamma_3$"];
    a_1 -> a_2 [label=" ", texlbl="$x_1+x_3^2+z+c+v~~$"];
    a_2 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[mathmode,autosize]
digraph G {
    node [shape=rectangle];
    a_1 [margin="0"];
    a_2 [margin="0.7,0.4"];
    a_3 [width="2",height="1"];
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}
digraph G {
    d2toptions="-tmath --autosize --nominsize";
    node [shape=rectangle];
    a_1 [margin="0"];
    a_2 [margin="0.7,0.4"];
    a_3 [width="2",height="1"];
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[fdp,straightedges]
graph G {
    node [shape=circle, fixedsize=True, width="0.2",
          style="ball color =green", label=""];
    edge [style="snake=zigzag, green"];
    a_1 -- c -- a_2;
    c [style="ball color=black"];
    edge [style="snake=snake, blue"];
    node [style="ball color = red", label=""];
    a_3 -- c -- a_4 --a_3;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[circo,mathmode,shell]
digraph G {
    graph [mindist=0.5];
    node [fixedsize=true, shape=circle, width=0.4, style="fill=green!20"];
    c -> n_1 [style="-stealth"];
    c -> n_2 [style="-to"];
    c -> n_3 [style="-latex"];
    c -> n_4 [style="-diamond"];
    c -> n_5 [style="-o"];
    c -> n_6 [style="{-]}"];
    c -> n_7 [style="-triangle 90"];
    c -> n_8 [style="-hooks"];
    c -> n_9 [style="->>"];
    c [style="fill=red!80"];
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}
digraph G {
        node [shape=circle];
        a -> b [label="label",lblstyle="draw=red,cross out"];
        b -> c [label="test",lblstyle="below=0.5cm,rotate=20,fill=blue!20"];
        a [label="aa",lblstyle="blue"];
        b [lblstyle="font=\Huge"];
        c [label="ccc", lblstyle="red,rotate=90"];
        label="Graph label";
        lblstyle="draw,fill=red!20";
        rankdir=LR;
    }
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[tikz,circo]
digraph G {
        mindist = 0.5;
        node [shape="circle"];
        a -> b [topath="bend right"];
        c -> b [topath="bend left"];
        c -> a [topath="out=10,in=-90"];
        b -> b [topath="loop above"];
    }
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[tikz,neato,tikzedgelabels,styleonly]
digraph G {
        d2tfigpreamble = "\tikzstyle{every state}= \
        [draw=blue!50,very thick,fill=blue!20]";
        node [style="state"];
        edge [lblstyle="auto",topath="bend left"];
        A [style="state, initial"];
        A -> B [label=2];
        A -> D [label=7];
        B -> A [label=1];
        B -> B [label=3,topath="loop above"];
        B -> C [label=4];
        C -> F [label=5];
        F -> B [label=8];
        F -> D [label=7];
        D -> E [label=2];
        E -> A [label="1,6"];
        F [style="state,accepting"];
    }
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[mathmode,shell]
digraph G {
    d2tfigpreamble="\Huge";
    a_1-> a_2 -> a_3 -> a_1;
}
\end{dot2tex}
\end{preview}

\begin{preview}
\begin{dot2tex}[tikz,shell,prog=neato,mathmode]
digraph G {
    node [shape="circle"];
  a_1 -> a_2 -> a_3 -> a_4 -> a_1;
}
\end{dot2tex}
\end{preview}

% Define layers
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
% The scale option is useful for adjusting spacing between nodes.
% Note that this works best when straight lines are used to connect
% the nodes.
\begin{preview}
\begin{tikzpicture}[>=latex',scale=0.8]
    % set node style
    \tikzstyle{n} = [draw,shape=circle,minimum size=2em,
                        inner sep=0pt,fill=red!20]
    \begin{dot2tex}[dot,tikz,codeonly,options=-s --styleonly -tmath]
        digraph G  {
            node [style="n"];
            A_1 -> B_1; A_1 -> B_2; A_1 -> B_3;
            B_1 -> C_1; B_1 -> C_2;
            B_2 -> C_2; B_2 -> C_3;
            B_3 -> C_3; B_3 -> C_4;
        }
    \end{dot2tex}
    % annotations
    \node[left=1em] at (C_1.west)  (l3) {Level 3};
    \node at (l3 |- B_1) (l2){Level 2};
    \node at (l3 |- A_1) (l1) {Level 1};
    % Draw lines to separate the levels. First we need to calculate
    % where the middle is.
    \path (l3) -- coordinate (l32) (l2) -- coordinate (l21) (l1);
    \draw[dashed] (C_1 |- l32) -- (l32 -| C_4);
    \draw[dashed] (C_1 |- l21) -- (l21 -| C_4);
    \draw[<->,red] (A_1) to[out=-120,in=90] (C_2);
    % Highlight the A_1 -> B_1 -> C_2 path. Use layers to draw
    % behind everything.
    \begin{pgfonlayer}{background}
        \draw[rounded corners=2em,line width=3em,blue!20,cap=round]
                (A_1.center) -- (B_1.west) -- (C_2.center);
    \end{pgfonlayer}
\end{tikzpicture}
\end{preview}

\end{document}
