少于 4 位数字的节点看起来较小。我希望它们都具有相同的大小,但我似乎无法理解足够的文档来做到这一点。请随时向我提出更好的方法。我希望能够定义一个函数 $f(x) = x^2 + 8 \mod 3127$,其中 $x_0 = 2$ 就是这些数字的来源。
\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}
答案1
您希望控制节点大小。因此,您可以使用minimum width
。例如:
在这种情况下,您不需要[draw, circle]
一直写。
(另外,考虑使用foreach
。)
平均能量损失
\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}
答案2
PSTricks 解决方案只是为了节省更多击键。
\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}
使用 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}