I need to typeset graphs but I do not want to place the nodes by hand. I use the dot2texi package to automatically translate graph descriptions into tikz/pgf commands. This works great.
I also want to create beamer slides to illustrate the action of graph algorithms (DFS, Prim, etc.). I thus need to highlight nodes, which I do by drawing colored nodes on a background layer at the same positions as the nodes generated by dot2texi. This also works.
I need to highlight edges too. My source for highlighting nodes does edges in the same manner: they are redrawn thanks to knowing their endpoints. This works there because the edges are straight.
In my case, edges are bent in a manner I do not know (and do not want to know), so knowing both endpoints is not sufficient.
It is possible to reuse a path for a second drawing thanks to this SX question & answer. I tried and this also works.
But this requires to give the paths a name (in contrast to nodes which are referencable in their own right) during their creation, which in my case is automated.
Currently, I am cheating with the style feature of the dot language: it happens to put the text I need at the right place in the generated tikz commands when run through dot2texi.
\documentclass{article}
\usepackage{dot2texi}
\usepackage{tikz}
\tikzstyle{basevertex} = [circle,
inner sep=0pt,
minimum size=.5cm,
font=\scriptsize]
\tikzstyle{vertex} = [basevertex, draw]
\tikzstyle{dotvertex} = [vertex]
\tikzstyle{selected edge} = [draw,line width=5pt,-,red!50]
%% here follows the code from [2]
%%% etc.
\begin{document}
\begin{tikzpicture}
\begin{dot2texi}[codeonly, styleonly, tikz]
graph G {
rankdir="LR";
node[style="dotvertex", fontsize=8];
0 -- 1 -- 3;
0 -- 2 -- 3 -- 4;
3 -- 7;
2 -- 6;
5 -- 2;
5 -- 4 [style="name path global=test"];
}
\end{dot2texi}
\begin{pgfonlayer}{background}
\path[use path=test, selected edge];
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
gives, as intended,
I am now trying to automate the naming/styling of path according to their endpoints (I will not typeset multigraphs), like edge(origin)(destination) so that I can refer them without bothering to manually name them in my dot code.
