# How to make all circles in this example have the same radii?

The nodes with less than 4 digits appear smaller. I'd like to have them all of the same size and I can't seem to understand enough of the documentation to get it right. Feel free to suggest me a better way to do this. I'd love to be able to define a function $f(x) = x^2 + 8 \mod 3127$ with $x_0 = 2$ which is where these numbers come from.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}

\def \n {11}
\def \margin {10}

\def \s {1}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$456$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {2}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$1562$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {3}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$792$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {4}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$1872$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {5}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2152$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {6}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$25$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {7}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$441$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {8}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$615$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {9}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2993$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {10}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2329$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {11}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2031$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\end{tikzpicture}
\end{document}

• What you want is to control the node size. – Sigur Jan 8 at 13:36
• Your modulus function should produce labels as shown in my last edit. – Money Oriented Programmer Jan 8 at 23:06

What you wish is to control the node size. So, you can use minimum width. For example:

In this case, you don't need to write [draw, circle] all the time.

(Also, consider using foreach.)

MWE

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={circle,draw,minimum width=1.2cm}]

\def \n {11}
\def \margin {10}

\def \s {1}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$456$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {2}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$1562$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {3}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$792$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {4}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$1872$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {5}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2152$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {6}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$25$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {7}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$441$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {8}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$615$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {9}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2993$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {10}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2329$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\def \s {11}
\node[draw, circle] at ({360/\n * (\s - 1)}:\radius) {$2031$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);

\end{tikzpicture}
\end{document}

• How can I use a foreach and still automatically place the text inside the circles? – Joep Awinita Jan 8 at 15:50

A PSTricks solution just for saving more keystrokes.

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node}
\degrees[11]
\begin{document}
\foreach \l [count=\i from 0] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{\Cnodeput(!4 \i\space PtoCrel){A\i}{\l}}
\foreach \i [count=\j from 1] in {0,...,10}
{
\ifnum\i=10
\ncarc{A0}{A10}
\else
\ncarc{A\j}{A\i}
\fi
}
\end{pspicture}
\end{document}


# Using f(x) = x*x + 8 (mod 3127)

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node,pst-calculate}
\makeatletter
\def\f#1{\pst@mod{\pscalculate{(#1+2)**2+8}}{3127}\x\x}
\degrees[11]
\begin{document}