defense/src/fig/app/tspels.tex

105 lines
3.6 KiB
TeX

\begin{tikzpicture}
\input{src/tikz/tsp}
\tspnodes
\def\bhstep{2.6}
\def\shstep{.75}
\def\vstep{-1.5}
\def\ratioodd{.666}
\def\ratioeven{.85}
%{{{ first line "
\def\cl{1}
\begin{scope}[visible on=<3->,every path/.append style={visible on=<3->}]
\foreach \i in {0,...,\last} {
\coordinate (p-\cl-\i) at ($(p\i)!\ratioodd!(0,0)+(0,\vstep*\cl)$);
\node[tsp/node,minimum size=2pt] at (p-\cl-\i) {};
}
%{{{ boxes "
\begin{scope}[on background layer]
\node[fit=(p-\cl-0)(p-\cl-1)(p-\cl-2)(p-\cl-3)(p-\cl-4)(p-\cl-5)(p-\cl-6)(p-\cl-7)(p-\cl-8)(p-\cl-9),
rectangle,rounded corners] (sol-\cl) {};
\end{scope}
%}}}
\foreach [count=\i from 0] \o in {2,1,0,9,8,7,4,3,5,6} { \coordinate (s-\cl-\i) at (p-\cl-\o); }
\begin{scope}[on background layer]
\draw[tsp/edge,semithick,foreach/.style={insert path=--(s-\cl-#1)}] (s-\cl-0) [foreach/.list={1,...,\last}] -- cycle;
\end{scope}
\end{scope}
%}}}
%{{{ second line "
\def\cl{2}
\begin{scope}[visible on=<4->,every path/.append style={visible on=<4->}]
\foreach \l in {0,...,2} {
\foreach \i in {0,...,\last} {
\coordinate (p-\cl-\i-\l) at ($(p\i)!\ratioeven!(0,0)+(\shstep*\l-.47,\vstep*\cl+.5)$);
\node[tsp/node,minimum size=1pt] at (p-\cl-\i-\l) {};
}
% box
\begin{scope}[on background layer]
\ifthenelse{\l=2}
{\tikzset{local/.style={only on=<5>{tsp/best,thin}}}}
{\tikzset{local/.style={}}}
\node[fit=(p-\cl-0-\l)(p-\cl-1-\l)(p-\cl-2-\l)(p-\cl-3-\l)(p-\cl-4-\l)(p-\cl-5-\l)(p-\cl-6-\l)(p-\cl-7-\l)(p-\cl-8-\l)(p-\cl-9-\l),
local,rectangle,rounded corners,inner sep=1pt] (sol-\cl-\l) {};
\end{scope}
}
%{{{ third column "
\foreach [count=\i from 0] \o in {2,1,0,4,8,7,9,3,5,6} { \coordinate (s-\cl-\i-0) at (p-\cl-\o-0); }
\foreach [count=\i from 0] \o in {2,3,0,9,8,7,4,1,5,6} { \coordinate (s-\cl-\i-1) at (p-\cl-\o-1); }
\foreach [count=\i from 0] \o in {2,1,0,9,8,7,4,6,5,3} { \coordinate (s-\cl-\i-2) at (p-\cl-\o-2); }
\begin{scope}[on background layer]
\draw[tsp/edge,very thin,foreach/.style={insert path=--(s-\cl-#1-0)}] (s-\cl-0-0) [foreach/.list={1,...,\last}] -- cycle;
\draw[tsp/edge,very thin,foreach/.style={insert path=--(s-\cl-#1-1)}] (s-\cl-0-1) [foreach/.list={1,...,\last}] -- cycle;
\draw[tsp/edge,very thin,foreach/.style={insert path=--(s-\cl-#1-2)}] (s-\cl-0-2) [foreach/.list={1,...,\last}] -- cycle;
\end{scope}
%}}}
\end{scope}
%}}}
%{{{ third line "
\def\cl{3}
\begin{scope}[visible on=<6->,every path/.append style={visible on=<6->}]
\foreach \i in {0,...,\last} {
\coordinate (p-\cl-\i) at ($(p\i)!\ratioodd!(0,0)+(0,\vstep*\cl+.5)$);
\node[tsp/node,minimum size=2pt] at (p-\cl-\i) {};
}
\foreach [count=\i from 0] \o in {2,1,0,9,8,7,4,6,5,3} { \coordinate (s-\cl-\i) at (p-\cl-\o); }
\foreach \i in {0,...,\last} {
\node[tsp/node,minimum size=2pt] at (p-\cl-\i) {};
}
%{{{ boxes "
\begin{scope}[on background layer]
\node[fit=(p-\cl-0)(p-\cl-1)(p-\cl-2)(p-\cl-3)(p-\cl-4)(p-\cl-5)(p-\cl-6)(p-\cl-7)(p-\cl-8)(p-\cl-9),
rectangle,rounded corners] (sol-\cl) {};
\end{scope}
%}}}
\begin{scope}[on background layer]
\draw[tsp/edge,semithick,foreach/.style={insert path=--(s-\cl-#1)}] (s-\cl-0) [foreach/.list={1,...,\last}] -- cycle;
\end{scope}
\end{scope}
%}}}
%{{{ links "
\foreach \l in {0,...,2} {
\draw[<-,>=stealth,visible on=<4->] (sol-2-\l) -- (sol-1);
}
\foreach \l in {0,...,2} {
\draw[->,>=stealth,visible on=<6->] (sol-2-\l) -- (sol-3);
}
%}}}
%{{{ loop "
\draw[->,>=stealth,semithick,rounded corners,visible on=<7>] (sol-3.south) -- ++(0,-3mm) -| ([xshift=-5mm]sol-1.west) -- (sol-1);
%}}}
\end{tikzpicture}