defense/src/fig/app/tspgreedysolution.tex

36 lines
1.2 KiB
TeX

\begin{tikzpicture}
\input{src/tikz/tsp}
\tspnodes
% \def\tspstart{0}
\coordinate (E) at (p\tspstart);
\ifthenelse{\tspstart=0}{\def\tspsolution{0,9,1,8,7,6,4,2,3,5}}{}
\ifthenelse{\tspstart=1}{\def\tspsolution{1,8,7,9,0,2,4,5,6,3}}{}
\ifthenelse{\tspstart=2}{\def\tspsolution{2,1,0,9,8,7,4,3,5,6}}{}
\ifthenelse{\tspstart=3}{\def\tspsolution{3,4,5,6,8,7,1,2,0,9}}{}
\ifthenelse{\tspstart=4}{\def\tspsolution{4,5,3,6,8,7,1,2,0,9}}{}
\ifthenelse{\tspstart=5}{\def\tspsolution{5,4,3,6,8,7,1,2,0,9}}{}
\ifthenelse{\tspstart=6}{\def\tspsolution{6,4,5,3,8,7,1,2,0,9}}{}
\ifthenelse{\tspstart=7}{\def\tspsolution{7,8,6,4,5,1,9,0,2,3}}{}
\ifthenelse{\tspstart=8}{\def\tspsolution{8,7,6,4,5,1,9,0,2,3}}{}
\ifthenelse{\tspstart=9}{\def\tspsolution{9,0,1,8,7,6,4,5,3,2}}{}
\foreach [count=\i from 0] \o in \tspsolution {
\coordinate (s\i) at (p\o);
}
\foreach \i in {0,...,\last} {
\node[tsp/node] at (p\i) {};
}
\node[tsp/node,common/drawfillf={black}{20}] at (E) {};
\ifthenelse{\istep=0}{}{
\begin{scope}[on background layer]
\draw[tsp/edge,foreach/.style={insert path=--(s#1)}] (E) [foreach/.list={1,...,\istep}] -- cycle;
\end{scope}
}
\end{tikzpicture}