Necessary utilities: graphviz, dot2tex, xsel. Install these:
$ sudo apt install graphviz
$ sudo apt install xsel
$ pip3 install dot2tex
(May differ on your system - xsel probably already installed).
Now simply do dot2tex --figonly | xsel -i -b
Type in the dot code for your graph, e.g.
graph foo {
a -- b;
b -- c;
}
then hit CTRL-D for EOF, and the code will be added to your clipboard!
\begin{tikzpicture}[>=latex,line join=bevel,]
\pgfsetlinewidth{1bp}
%%
\pgfsetcolor{black}
% Edge: a -- b
\draw [] (27.0bp,143.83bp) .. controls (27.0bp,133.0bp) and (27.0bp,119.29bp) .. (27.0bp,108.41bp);
% Edge: b -- c
\draw [] (27.0bp,71.831bp) .. controls (27.0bp,61.0bp) and (27.0bp,47.288bp) .. (27.0bp,36.413bp);
% Node: a
\begin{scope}
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,162.0bp) ellipse (27.0bp and 18.0bp);
\draw (27.0bp,162.0bp) node {a};
\end{scope}
% Node: b
\begin{scope}
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,90.0bp) ellipse (27.0bp and 18.0bp);
\draw (27.0bp,90.0bp) node {b};
\end{scope}
% Node: c
\begin{scope}
\definecolor{strokecol}{rgb}{0.0,0.0,0.0};
\pgfsetstrokecolor{strokecol}
\draw (27.0bp,18.0bp) ellipse (27.0bp and 18.0bp);
\draw (27.0bp,18.0bp) node {c};
\end{scope}
%
\end{tikzpicture}
- For a left-right oriented graph, add the line
rankdir="LR";
at the beginning of your graph (after thegraph foo{
). - For a different graph layout, add the option
--prog neato
todot2tex