# Wrong anchor for nodes when using \pgfmathparse

I have this example

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\foreach \i in {0,2,...,10}
{\node[circle,draw] (\i) at (0,\i) {\i}; }

\foreach \i in {1,3,...,11}
{\node[circle,draw] (\i) at (2,\i) {\i}; }

\foreach \i in {0,2,...,8}
{\pgfmathparse{\i+1}\draw (\i)--(\pgfmathresult);}

\draw (10)--(11);

\end{tikzpicture}

\end{document}


With this output Why lines on right nodes go to east side?

The result is a decimal e.g. 1.0 and this is a point on the border. You need an integer 1:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\foreach \i in {0,2,...,10}
{\node[circle,draw] (\i) at (0,\i) {\i}; }

\foreach \i in {1,3,...,11}
{\node[circle,draw] (\i) at (2,\i) {\i}; }

\foreach \i in {0,2,...,8}
{\pgfmathparse{int(\i+1)}\draw (\i)--(\pgfmathresult);}

\draw (10)--(11);

\end{tikzpicture}

\end{document} Ulrike gave you the reason why it trips up. But you can also shorten things a bit. Here are two examples of even-odd comparison which gives the same result. Also for simple expressions it is generally sufficient to use \numexpr\x-1\relax (if extra expansion is needed then you can prefix it with \number)

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach\x[evaluate={\xx=isodd(\x)*2},count=\xi from -1]in{0,...,11}{
\node[circle,draw] (n-\x) at (\xx,\x) {\x};
\ifodd\x\relax\draw (n-\x) -- (n-\xi);\fi
}
\end{tikzpicture}
\end{document}