我尝试修改此网站上之前的 Cayley graph 帖子中的 latex 代码,但箭头连接不正确。前五个节点的图像看起来还不错,但之后就散了。我试图制作一个像下面附上的图像。抱歉有多个帐户,我将我的电子邮件连接到该帐户,这样我就不必再以访客身份发帖,我可以回复评论,这是我在之前的帖子中无法做到的。我提供了一个最低限度的工作示例,任何反馈都会有所帮助。
\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.markings,arrows.meta}
\begin{document}
\begin{tikzpicture}[mid arrow/.style={postaction={
decoration={markings, mark=at position 0.5 with {\arrow{Triangle}}},
decorate}},looseness=0.5]
\foreach \i [count=\j, count=\r from 0] in {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}{
\node (r\j) at (90+36-\j*36:3/2) {$\ifnum\i=1e\else r_\r\fi$};
}
\foreach \i [evaluate={\j=int(mod(\i, 5)+1);}] in {1,...,10}{
\draw [blue, mid arrow] (r\i) to [bend left] node [auto] {$r_1$} (r\j);
\draw [purple, mid arrow] (r\j) to [bend left] node [auto] {$r_1$} (r\i);
}
\end{tikzpicture}
\end{document}
答案1
像这样的东西?但如果您要绘制其中的几个,您迟早需要坐下来阅读 TikZ 手册并阅读与您的需求相关的部分。
\documentclass[border=10pt,tikz,multi]{standalone}
\usetikzlibrary{decorations.markings,arrows.meta}
\begin{document}
\begin{tikzpicture}
[
mid arrow/.style={%
postaction={%
decoration={%
markings, mark=at position 0.5 with {\arrow{Triangle}},
},
decorate,
},
},
my label/.style={%
auto, midway, font=\footnotesize, inner sep=1.5pt
},
looseness=0.5
]
\colorlet{my colour}{black}%
\foreach \i [count=\j, count=\r from 0, evaluate=\j as \k using {90+36-\j*36}] in {1,...,10}{
\node [circle, fill, inner sep=0pt, minimum width=2.5pt, label={\k:$\ifnum\i=1e\else r_\r\fi$}] (r\j) at (90+36-\j*36:3/2) {};
}
\foreach \i [evaluate={\j=int(mod(\i,10)+1);}] in {1,...,10}{
\ifodd\j \colorlet{my colour}{blue}\def\tempa{$d_1$}\else \colorlet{my colour}{purple}\def\tempa{$d_2$}\fi
\draw [my colour, mid arrow] (r\i) to [bend left] node [my label] {\tempa} (r\j);
\draw [my colour, mid arrow] (r\j) to [bend left] node [my label] {\tempa} (r\i);
}
\end{tikzpicture}
\end{document}