如何创建下图?

如何创建下图?

如何创建下图?

期望输出

答案1

欢迎!这里有一个建议:将节点放入矩阵中,并用中间带有箭头的圆弧/直线将它们连接起来,箭头弯曲并沿着边缘。

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{matrix,decorations.markings,arrows.meta,bending}
\tikzset{% 
    attach arrow/.style={
    decoration={
        markings,
         mark=at position 0 with {\pgfextra{%
         \pgfmathsetmacro{\tmpArrowTime}{\pgfkeysvalueof{/tikz/arc arrow/length}/(\pgfdecoratedpathlength)}%
         \xdef\tmpArrowTime{\tmpArrowTime}}},
        mark=at position {#1-3*\tmpArrowTime} with {\coordinate(@1);},
        mark=at position {#1-2*\tmpArrowTime} with {\coordinate(@2);},
        mark=at position {#1-1*\tmpArrowTime} with {\coordinate(@3);},
        mark=at position {#1+\tmpArrowTime/2} with {\coordinate(@4);
        \draw[-{Stealth[length=\pgfkeysvalueof{/tikz/arc arrow/length},bend]}] plot[smooth]
         coordinates {(@1) (@2) (@3) (@4)};},
        },
     postaction=decorate,
     },
     attach arrow/.default=0.5,
     arc arrow/.cd,length/.initial=2mm,
}

\begin{document}
\begin{tikzpicture}[s/.style={alias=#1,execute at begin node=#1},>=stealth]
\matrix[matrix of nodes,nodes={circle,draw,font=\sffamily},
    row sep=2em,column sep=2em] {
    & |[s=R]| & & & \\
    |[s=X]| & & |[s=Y]| & & |[s=Z]|\\
    & |[s=S]| & & &\\ 
    };
\path[every edge/.append style={attach arrow}] 
 foreach \X/\Y in {X/R,R/Y,X/S} 
 {(\X) edge[bend left] (\Y) (\X) edge[bend right] (\Y) (\X) edge (\Y)}
 foreach \X/\Y in {Y/Z,S/Y}
 {(\X) edge[bend left] (\Y) (\X) edge[bend right] (\Y)}
 (X) edge (Y) 
 (R) edge[bend left] (Z)
 (S) edge[bend right] (Z) 
 (S) edge[bend right=45] (Z);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

很高兴重新发现我十年没用过的包裹

首先,创建顶点。您可以定义相对于其他顶点的位置。很容易理解 NO(北)SO EA WE 和 NOEA NOWE 等...然后在安装边之前定义每个边的样式。您可以将多个具有相同样式的边连接起来。

\documentclass[border=.25cm]{standalone}
\usepackage{tkz-graph}\usetikzlibrary{decorations.markings} %
\tikzset{->-/.style={
 decoration={ markings, mark=at position #1 with {\arrow{>}}},
   postaction={decorate}},
  ->-/.default=0.5 
}
\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Normal]
\SetGraphUnit{4}
\Vertex{X}
\NOEA(X){R}\SOEA(X){S}\SOEA(R){Y}\EA(Y){Z}

\tikzset{EdgeStyle/.style = {->-,>=stealth',bend right}} 
\Edges(X,R,Y)\Edges(X,S,Y,Z)
\tikzset{EdgeStyle/.style = {->-,>=stealth'}} 
\Edges(X,R,Y)\Edges(X,S)
\tikzset{EdgeStyle/.style = {->-,>=stealth',bend left}} 
\Edges(X,R,Y)\Edges(X,S,Y,Z)
\end{tikzpicture}
\end{document}

有一些风格

\GraphInit[vstyle=Shade]
\renewcommand*{\VertexInnerSep}{8pt}
\renewcommand*{\EdgeLineWidth}{3pt}
\renewcommand*{\VertexBallColor}{blue!10}

在此处输入图片描述

在此处输入图片描述

相关内容