我正在尝试重新创建 $\mathbb{Z}$ 相对于生成器集 ${2, 3}$ 的凯莱图。理想情况下,我想要类似以下内容:
以下是我的尝试,我将自行添加更多顶点,但我想改变(但做不到)的是“无穷远处的行为”:我希望极值边缘不要闭合,而是像上图那样终止。我该如何实现这一点?
\documentclass[usenames,dvipsnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pifont}
\usepackage{tikz-cd}
\begin{tikzpicture}[scale=0.7]
\draw[thick, color=OliveGreen] (0, 0) to [bend left=40] (2, 0);
\draw[thick, color=OliveGreen] (1, 0) to [bend left=40] (3, 0);
\draw[thick, color=OliveGreen] (-1, 0) to [bend left=40] (1, 0);
\draw[thick,color=OliveGreen] (-2, 0) to [bend left=40] (0, 0);
\draw[thick, color=OliveGreen] (-3, 0) to [bend left=40] (-1, 0);
\draw[thick, color=BurntOrange] (0, 0) to [bend right=55] (3, 0);
\draw[thick, color=BurntOrange] (-1, 0) to [bend right=55] (2, 0);
\draw[thick, color=BurntOrange] (-2, 0) to [bend right=55](1, 0);
\draw[thick, color=BurntOrange] (-3, 0) to [bend right=55] (0, 0);
\node at (0,0.7) {0};
\node at (-1,0.7) {-1};
\node at (1,0.7) {1};
\node at (2,0.7) {2};
\node at (-2,0.7) {-2};
\draw[fill=black] (0,0) circle (3pt);
\draw[fill=black] (-1,0) circle (3pt);
\draw[fill=black] (1,0) circle (3pt);
\draw[fill=black] (2,0) circle (3pt);
\draw[fill=black] (-2,0) circle (3pt);
\end{tikzpicture}
答案1
你可以剪掉不需要的部分。使用循环是有意义的。
\documentclass[usenames,dvipsnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{tikz}
\tikzset{Cayley/.cd,nmin/.initial=-4,nmax/.initial=4}
\newcommand\CayleyGraph[2][]{\begin{tikzpicture}[#1,Cayley/.cd,#2]
\def\pv##1{\pgfkeysvalueof{/tikz/Cayley/##1}}
\clip (\pv{nmin}-0.8,-0.6) rectangle (\pv{nmax}+0.8,0.6);
\foreach \X in {\the\numexpr\pv{nmin}-2,\the\numexpr\pv{nmin}-1,...,\the\numexpr\pv{nmax}+1}
{
\draw[thick,OliveGreen] (\X,0) sin (\X+1,-0.5) cos (\X+2,0);
\draw[thick,BurntOrange] (\X,0) sin (\X+1,0.5) cos (\X+2,0);
\ifnum\X<\numexpr\pv{nmax}+1
\path (\X,0) node[circle,inner sep=1.4pt,fill,label=left:{$\X$}]{};
\fi
}
\end{tikzpicture}}
\begin{document}
\begin{frame}[t]
\frametitle{A Cayley graph}
\begin{figure}
\centering
\CayleyGraph{nmin=-4,nmax=4}
\end{figure}
\end{frame}
\end{document}
或者
\documentclass[usenames,dvipsnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{tikz}
\tikzset{Cayley/.cd,nmin/.initial=-4,nmax/.initial=4}
\newcommand\CayleyGraph[2][]{\begin{tikzpicture}[#1,Cayley/.cd,#2]
\def\pv##1{\pgfkeysvalueof{/tikz/Cayley/##1}}
\clip (\pv{nmin}-0.8,-0.6) rectangle (\pv{nmax}+0.8,0.6);
\foreach \X in {\the\numexpr\pv{nmin}-3,\the\numexpr\pv{nmin}-2,...,\the\numexpr\pv{nmax}+1}
{
\draw[thick,OliveGreen] (\X,0) to[out=-30,in=180] (\X+1,-0.5) to[out=0,in=-150] (\X+2,0);
\draw[thick,BurntOrange] (\X,0) to[out=20,in=180](\X+1.5,0.5) to[out=0,in=160] (\X+3,0);
\ifnum\X<\numexpr\pv{nmax}+1
\path (\X,0) node[circle,inner sep=1.4pt,fill,label=left:{$\X$}]{};
\fi
}
\end{tikzpicture}}
\begin{document}
\begin{frame}[t]
\frametitle{A Cayley graph}
\begin{figure}
\centering
\CayleyGraph{nmin=-4,nmax=4}
\end{figure}
\end{frame}
\end{document}