| 1 |
\documentclass{article} |
| 2 |
\usepackage{tikz} |
| 3 |
\usetikzlibrary{arrows,shapes} |
| 4 |
\usepackage{dot2texi} |
| 5 |
\begin{document} |
| 6 |
% Define layers |
| 7 |
\pgfdeclarelayer{background} |
| 8 |
\pgfdeclarelayer{foreground} |
| 9 |
\pgfsetlayers{background,main,foreground} |
| 10 |
|
| 11 |
% The scale option is useful for adjusting spacing between nodes. |
| 12 |
% Note that this works best when straight lines are used to connect |
| 13 |
% the nodes. |
| 14 |
\begin{tikzpicture}[>=latex',scale=0.8] |
| 15 |
% set node style |
| 16 |
\tikzstyle{n} = [draw,shape=circle,minimum size=2em, |
| 17 |
inner sep=0pt,fill=red!20] |
| 18 |
\begin{dot2tex}[dot,tikz,codeonly,styleonly,options=-s -tmath] |
| 19 |
digraph G { |
| 20 |
node [style="n"]; |
| 21 |
A_1 -> B_1; A_1 -> B_2; A_1 -> B_3; |
| 22 |
B_1 -> C_1; B_1 -> C_2; |
| 23 |
B_2 -> C_2; B_2 -> C_3; |
| 24 |
B_3 -> C_3; B_3 -> C_4; |
| 25 |
} |
| 26 |
\end{dot2tex} |
| 27 |
% annotations |
| 28 |
\node[left=1em] at (C_1.west) (l3) {Level 3}; |
| 29 |
\node at (l3 |- B_1) (l2){Level 2}; |
| 30 |
\node at (l3 |- A_1) (l1) {Level 1}; |
| 31 |
% Draw lines to separate the levels. First we need to calculate |
| 32 |
% where the middle is. |
| 33 |
\path (l3) -- coordinate (l32) (l2) -- coordinate (l21) (l1); |
| 34 |
\draw[dashed] (C_1 |- l32) -- (l32 -| C_4); |
| 35 |
\draw[dashed] (C_1 |- l21) -- (l21 -| C_4); |
| 36 |
\draw[<->,red] (A_1) to[out=-120,in=90] (C_2); |
| 37 |
% Highlight the A_1 -> B_1 -> C_2 path. Use layers to draw |
| 38 |
% behind everything. |
| 39 |
\begin{pgfonlayer}{background} |
| 40 |
\draw[rounded corners=2em,line width=3em,blue!20,cap=round] |
| 41 |
(A_1.center) -- (B_1.west) -- (C_2.center); |
| 42 |
\end{pgfonlayer} |
| 43 |
\end{tikzpicture} |
| 44 |
\end{document} |