如何创建具有多个节点的循环?

如何创建具有多个节点的循环?

我想做这个

\documentclass{article}
\usepackage{tikz}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{textcomp}
\usetikzlibrary{arrows,snakes,automata,backgrounds,calc, positioning,quotes}
\usetikzlibrary{decorations.pathmorphing}
\pagenumbering{gobble}
\begin{document}
\centering 

\vfill

%\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,thick,main node/.style={circle,fill=#1!0,draw,font=\sffamily\Large\bfseries}]

\begin{tikzpicture}[
        ->,    > = stealth',
       shorten > = 1pt,auto,
   node distance = 3cm,
      decoration = {snake,   % <-- added
                    pre length=3pt,post length=7pt,% <-- for better looking of arrow,
                    },
main node/.style = {circle,draw,fill=#1!0,
                    font=\sffamily\Large\bfseries},
                    ]

\node[main node=black] (0) {$\omega$};
\node[main node=black] (1)[above of=0] {$\alpha$};
\node[main node=black] (2) [above of=1]{$\alpha_0$};
\node[main node=black](3)[above of=2]{$\alpha_1$};
\node[main node=black] (4) [above of=3]{$\beta$};
\node[main node=black](5)[right of=4]{$\beta_0$};
\node[](6)[above of =3]{};
\node[main node=black](7)[left of=4]{$\beta_1$};
\node[main node=black](8)[right of =1]{$\beta_1^{'}$};
\node[](9)[left of=8]{};
\node[main node=black](10)[right of=8]{$\beta_1^{''}$};
\node[](11)[right of=10]{};

  \path[every node/.style={font=\sffamily\small}]

    (0) edge[very thick, color=blue] node [] {} (1)
    (1) edge[very thick, color=magenta]node[right]{CHILD$_{oot}$}(2)
    (2) edge[draw=gray, very thick, decorate] node [right] {SEALED} (3)
    (3) edge[very thick, color=cyan] node [right] {ADULT$_{oot}$} (4)
    (4) edge[very thick, color=red]node[above]{DEFEAT}(5)
    (4) edge[very thick, color=green]node[above]{SUCCESS}(7)
    (10) edge[very thick, color=cyan]node[]{ADULT}(11)
    (1) edge[very thick, color=magenta]node[]{CHILD}(8)
    (8) edge[draw=gray, very thick, decorate]node[]{SEALED?}(10)
    (7) edge[bend right, very thick, draw=gray]node[left]{BACK IN TIME}(1)

   ;

\end{tikzpicture}
\end{document}

看起来像这样

在此处输入图片描述

我以前从未让箭头像这样绕着圆圈弯曲过。有什么想法吗?

答案1

我不确定您想要的节点的确切设置,因为似乎无法将 tikz 图的拓扑结构与您手工绘制的拓扑结构相匹配。

在此处输入图片描述

这个解决方案相当幼稚。

\documentclass[tikz, border =3pt]{standalone}
\usetikzlibrary{arrows,snakes}
\begin{document}

\begin{tikzpicture}
  [
            ->,    > = stealth',
           shorten > = 1pt,auto,
       node distance = 4cm,
          decoration = {snake,   % <-- added
                        pre length=3pt,post length=7pt,% <-- for better looking of arrow,
                        },
    main node/.style = {circle,draw,fill=#1!0,
                        font=\sffamily\Large\bfseries},
  ]
  \def\r{3.5}

  \node[main node=black] (2) at (0:\r) {$\alpha_0$};
  \node[main node=black] (3) at (90:\r) {$\alpha_1$};
  \node[main node=black] (4) at (180:\r) {$\beta$};
  \node[main node=black] (7) at (-90:\r) {$\beta_1$};
  \node[main node=black] (1) at (2|-7) {$\alpha$};
  \node[main node=black] (5) [left of=4] {$\beta_0$};
  \coordinate                (6) [above of=3] {};
  \node[main node=black] (0) [below of=1] {$\omega$};
  \node[main node=black] (8) [right of=1] {$\beta_1^{'}$};
  \coordinate                (9) [left of=8]  {};
  \node[main node=black] (10)[right of=8] {$\beta_1^{''}$};
  \node[]                (11)[right of=10]{};

  \path[every node/.style={font=\sffamily\small}]

    (0) edge[very thick, color=blue] node [] {} (1)
    (1) edge[very thick, color=magenta]node[right]{CHILD$_{oot}$}(2)
    (2) edge[draw=gray, very thick, decorate, in=0, out=90] node [anchor=south west] {SEALED} (3)
    (3) edge[very thick, color=cyan, in=90, out=180] node [anchor=south east] {ADULT$_{oot}$} (4)
    (4) edge[very thick, color=red]node[above]{DEFEAT}(5)
    (4) edge[very thick, color=green, in=180, out=-90]node[anchor=north east]{SUCCESS}(7)
    (10) edge[very thick, color=cyan]node[]{ADULT}(11)
    (1) edge[very thick, color=magenta]node[]{CHILD}(8)
    (8) edge[draw=gray, very thick, decorate]node[]{SEALED?}(10)
    (7) edge[very thick, draw=gray]node[anchor = north]{BACK IN TIME}(1)

   ;

\end{tikzpicture}
\end{document}

干杯,

相关内容