1

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.

A cycle of polynomial numbers

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

\def \n {11}
\def \radius {3.5cm}
\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. – The Inventor of God Jan 8 at 23:06
2

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

enter image description here

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 \radius {3.5cm}
\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
2

A PSTricks solution just for saving more keystrokes.

\documentclass[pstricks,12pt]{standalone}
\usepackage{pst-node}
\degrees[11]
\begin{document}
\begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
    \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}

enter image description here

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}
\begin{pspicture}[radius=16pt,arrows=->,nodesep=2pt,arrowinset=0](-5,-5)(5,5)
    \foreach \i in {0,1,...,10}{\Cnodeput(!4 \i\space PtoCrel){A\i}{\f{\i}}}
    \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}

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.