How to create the following diagram?
Asked
Active
Viewed 251 times
2 Answers
5
Welcome! Here is a proposal: put the nodes into a matrix, and connect them with arcs/straight lines with arrows in the middle whereby the arrows are bent and follow the edge.
\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}
5
It is a pleasure to rediscover my package that I have not used for 10 years
First you create the Vertex. You can define the positions relatively to others. It's easy to understand NO (north) SO EA WE and NOEA NOWE etc... Then before installing the edges you define the style of each Edge. You can concatenate several edges with the same style.
\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}
with some styles
\GraphInit[vstyle=Shade]
\renewcommand*{\VertexInnerSep}{8pt}
\renewcommand*{\EdgeLineWidth}{3pt}
\renewcommand*{\VertexBallColor}{blue!10}
Alain Matthes
- 95,075
-
I forgot one edge ! – Alain Matthes Dec 27 '19 at 04:52



