How would I go about in tikz to simply draw a cycle graph using a for loop? I have this at the moment, which doesn't work due to the addition not working as expected, but instead being registered as node '0+1' for example (instead of simply node '1').
\begin{tikzpicture}
%counterclockwise order starting top right
\node[draw=none,minimum size=3.15cm,regular polygon,regular polygon sides=6] (a) {};
\node (0) [inner sep=2pt, circle, fill, draw=black] at (a.corner 1) {};
\node (1) [inner sep=2pt, circle, fill, draw=black] at (a.corner 2) {};
\node (2) [inner sep=2pt, circle, fill, draw=black] at (a.corner 3) {};
\node (3) [inner sep=2pt, circle, fill, draw=black] at (a.corner 4) {};
\node (4) [inner sep=2pt, circle, fill, draw=black] at (a.corner 5) {};
\node (5) [inner sep=2pt, circle, fill, draw=black] at (a.corner 6) {};
\foreach \x in {0,1,...,5} {
\draw (\x) to (\x+1);
}
\end{tikzpicture}
Also, while I'm here, is there a way to avoid copy/pasting 6 times the node creation lines? Maybe there's a one-liner in tikz which creates a cycle of given length directly, but I'm also asking in case I'd like to create something more complex for which a one-liner might not exist.
EDIT:
I'm trying to make the following work right now (using mod as well), but I get an Arithmetic overflow, how to solve?
\begin{tikzpicture}
%counterclockwise order starting top right
\node[draw=none,minimum size=3.15cm,regular polygon,regular polygon sides=6] (a) {};
\node (0) [inner sep=2pt, circle, fill, draw=black] at (a.corner 1) {};
\node (1) [inner sep=2pt, circle, fill, draw=black] at (a.corner 2) {};
\node (2) [inner sep=2pt, circle, fill, draw=black] at (a.corner 3) {};
\node (3) [inner sep=2pt, circle, fill, draw=black] at (a.corner 4) {};
\node (4) [inner sep=2pt, circle, fill, draw=black] at (a.corner 5) {};
\node (5) [inner sep=2pt, circle, fill, draw=black] at (a.corner 6) {};
\foreach \x in {0,...,5} {
\def\y{Mod(\x+1,6)}
\draw (\x) to (\y);
}
\end{tikzpicture}

(node cs: name/.evaluated={int(\x+1)})or something withmodsince you want5be connected with0. But yes, there's a much better approach for this. What's your goal? Just some nodes placed in a circle and connected? – Qrrbrbirlbel Oct 06 '22 at 10:03(node cs: name/.evaluated=...)syntax you can also use\the\numexprinside the coordinate name. So the following works as well:\draw (\x) to (\the\numexpr\x+1\relax);– Skillmon Oct 06 '22 at 10:08\draw (\x) to (node cs: name/.evaluated={int({Mod(\x+1,6)})});at the moment, but for some reason, they're getting recognized as '1.0' instead of '1' for example, even though there's anint(...), any ideas? – J. Schmidt Oct 06 '22 at 10:09modof something. – Qrrbrbirlbel Oct 06 '22 at 10:09{}around mod/Mod. – Qrrbrbirlbel Oct 06 '22 at 10:19mod(), it's just a single value that needs special handling, so\ifnum\x=5 0\else\the\numexpr\x+1\relaxwould suffice (I tend to not know the TikZ niceties, so I stick to the eTeX things :)) – Skillmon Oct 06 '22 at 10:50\ifnumor similar things if they can't input valid TikZ in the first place and rather teach the solutions that TikZ brings with it and can be applied to much more complex problems. (I tend to now know the niceties of many LaTeX packages and fall back to the most primitive solutions, too. After all, there's probably a simple package where one could just write\eval{\x+1}.) – Qrrbrbirlbel Oct 06 '22 at 11:24\inteval{\x+1}is built into LaTeX nowadays :P Don't understand me wrong, I like seeing your TikZ solutions (and one of the upvotes of your answer was me). – Skillmon Oct 06 '22 at 12:05