我想在背面画一个有 4 个顶点的双线图

我想在背面画一个有 4 个顶点的双线图

有人能帮我画出下面的图表吗(一个连接所有顶点的图,其中每个顶点之间都有带有箭头的自循环)?
在此处输入图片描述

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\tikzset{main node/.style={circle,fill=black!20,draw,minimum size=1cm,inner sep=0pt}}
\begin{document}
  \begin{tikzpicture}
   %%node
    \begin{scope}[xshift=4cm]
    \node[main node] (1) {$1$};
    \node[main node] (2) [right = 2cm  of 1]  {$2$};
    \node[main node] (3) [below = 2cm  of 1] {$3$};
    \node[main node] (4) [right = 2cm  of 3] {$4$};
    \path[draw,thick]
    (1) edge node {} (2)
    (1) edge node {} (4)
    (3) edge node {} (2)
    (3) edge node {} (4)
    (2) edge node {} (2)
    ;
    \end{scope}
\end{tikzpicture}
\end{document}

答案1

您可以添加节点(1) edge [in=150,out=90,looseness=5,->] (1)来创建自循环(1),其中looseness 定义曲线的“松散”程度。

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{positioning}
\tikzset{main node/.style={circle,fill=black!20,draw,minimum size=1cm,inner sep=0pt}}
\begin{document}
 \begin{tikzpicture}
   %%node
    \begin{scope}[xshift=4cm,>=stealth]
    \node[main node] (1) {$1$};
    \node[main node] (2) [right = 2cm  of 1]  {$2$};
    \node[main node] (3) [below = 2cm  of 1] {$3$};
    \node[main node] (4) [right = 2cm  of 3] {$4$};
    \path[draw,thick]
    (1) edge  (2)
    (1) edge  (4)
    (3) edge  (2)
    (3) edge  (4)
    (2) edge  (2)
    (1) edge [in=150,out=90,looseness=5,->] (1)
    (2) edge [in=30, out=90,looseness=5,->] (2)
    (3) edge [in=150,out=90,looseness=5,->] (3)
    (4) edge [in=30, out=90,looseness=5,->] (4)
    ;
    \end{scope}
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容