# Tikz connecting nodes with draw to problem

I am trying to make a series of nodes that are all connected to each other in tikz. This is an MWE:

\documentclass{standalone}
\usepackage{tikz, pgfplots}

\begin{document}
\begin{tikzpicture}
\foreach \ip in {0, ..., 3} {
\node[draw, circle] (a\ip) at (2*\ip, 0) {};
}

\foreach \ip in {0, ..., 2} {
\pgfmathsetmacro{\minp}{\ip+1}
\foreach \jp in {\minp, ..., 3} {
\pgfmathsetmacro{\ango}{10*\jp - 10*\ip}
\pgfmathsetmacro{\angi}{180 - 10*\jp + 10*\ip}
\draw (a\ip) to[out=\ango, in=\angi] (a\jp);
}
}

\end{tikzpicture}
\end{document}


The result is:

Expected behaviour is that none of the lines would intersect the circle of the nodes, i.e. lines connecting the adjacent nodes should not intersect with the circles as is the case now.

You should specify \pgfmathsetmacro{\minp}{int(\ip+1)} with that int to get an integer \ip+1 result. Another option is to use \pgfmathtruncatemacro{\minp}{\ip+1} as pointed out by @percusse in a comment. Alternatively, just set a counter [count=\minp from 1] for your loop and use it.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\foreach \ip in {0, ..., 3} {
\node[draw, circle] (a\ip) at (2*\ip, 0) {};
}

\foreach \ip [count=\minp from 1]in {0, ..., 2} {
%\pgfmathsetmacro{\minp}{\ip+1}
\foreach \jp in {\minp, ..., 3} {
\pgfmathsetmacro{\ango}{10*\jp - 10*\ip}
\pgfmathsetmacro{\angi}{180 - 10*\jp + 10*\ip}
\draw (a\ip) to[out=\ango, in=\angi] (a\jp);
}
}

\end{tikzpicture}
\end{document}


• \pgfmathtruncatemacro ;) – percusse Mar 14 '16 at 20:14
• Yes, tikz hero -;) - I added it. – AboAmmar Mar 14 '16 at 21:00