重新定位图形边

重新定位图形边

我怎样才能将顶点 {q_1, q_2, q_3} 的循环和顶点 {空集} 分别放在这些顶点的上方和下方(如下图所示),而不是放在右侧?

在此处输入图片描述

这是我的.TEX:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usetikzlibrary{automata}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[
->, >=stealth,
node distance=3cm,
every state/.style={thick, fill=gray!10},
initial text={$I$},
]
\node[state, initial](Q1) at (0,0) {$\{q_1\}$};
\node[state,accepting] (Q3) at (6,0) {$\{q_4\}$};
\node[state] (V) at (0,-3) {$\varnothing$};
\node[xscale=2, transform shape,state] (Q2) at (3,0) {%
    \scalebox{0.5}[1]{$\{q_1,q_2,q_3\}$}};

\draw (Q1) edge [above] node {$a$} (Q2);
\draw (Q1) edge [left] node {$b,c$} (V);
\draw (Q2) edge [above] node {$b,c$} (Q3);
\draw (Q3) edge [below] node [pos = 0.44,below = 0.2] {$a,b,c$} (V);
\draw (V.20) .. controls +(40:3mm) and +(90:2mm) .. ([xshift=3.5mm] V.east)
node[right] {$a,b,c$} .. controls +(-90:2mm) and +(-40:3mm) .. (V.-20);
\draw (Q2.20) .. controls +(40:3mm) and +(90:2mm) .. ([xshift=3.5mm] Q2.east)
node[right] {$a$} .. controls +(-90:2mm) and +(-40:3mm) .. (Q2.-20);
\end{tikzpicture}
\end{document}

输出:

在此处输入图片描述

答案1

正如 @frougon 所评论的。这是一种实现方法:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usetikzlibrary{automata}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[
->, >=stealth,
node distance=3cm,
every state/.style={thick, fill=gray!10},
initial text={$I$},
]
\node[state, initial](Q1) at (0,0) {$\{q_1\}$};
\node[state,accepting] (Q3) at (6,0) {$\{q_4\}$};
\node[state] (V) at (0,-3) {$\varnothing$};
\node[xscale=2, transform shape,state] (Q2) at (3,0) {%
    \scalebox{0.5}[1]{$\{q_1,q_2,q_3\}$}};

\draw (Q1) edge [above] node {$a$} (Q2);
\draw (Q1) edge [left] node {$b,c$} (V);
\draw (Q2) edge [above] node {$a$} (Q3);
\draw (Q3) edge [below] node [pos = 0.44,below = 0.2] {$a,b,c$} (V);
\draw (V.-115) .. controls +(-130:3mm) and +(180:2mm) .. ([yshift=-3.5mm] V.south)
node[below] {$a,b,c$} .. controls +(0:2mm) and +(-50:3mm) .. (V.-65);
\draw (Q2.100) .. controls +(130:3mm) and +(180:2mm) .. ([yshift=3.5mm] Q2.north)
node[above] {$b,c$} .. controls +(0:2mm) and +(50:3mm) .. (Q2.80);
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

您的代码太复杂了。只需\draw(V)(V)以及 设置in=out=角度,再加上 即可looseness

\draw (V)to[out=250, in=290, looseness=3]node[below] {$a,b,c$}(V);
\draw (Q2)to[out=110, in=70, looseness=2]node[above] {$b,c$}(Q2);

在此处输入图片描述

答案3

基于我的答案关于你之前的问题:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usetikzlibrary{arrows.meta, automata,
                positioning,
                quotes,
                shapes}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[
                 > = Stealth,
     node distance = 11mm and 7mm,
 every edge/.style = {draw, ->},
every state/.style = {ellipse, draw, thick, fill=gray!15,
                      minimum size=2em, inner xsep=0pt},
      initial text = {$I$},
                    ]
\node (Q1)  [state, initial]        {$\{q_1\}$};
\node (Q2)  [state, right=of Q1]    {$\{q_1, q_2, q_3\}$};
\node (Q3)  [state, accepting,
             right=of Q2]           {$\{q_1\}$};
\node (Q4)  [state, below=of Q1]    {$\varnothing$};
\draw   (Q1) edge ["$a$"] (Q2)
        (Q2) edge [loop above, distance=7mm,"$a$"] (Q2)
        (Q2) edge ["$a$"]       (Q3)
        (Q1) edge ["${b,c}$"]   (Q4)
        (Q3) edge ["${a,b,c}$"] (Q4)
        (Q4) edge [loop left, distance=7mm,
                    "${a,b,c}$"] (Q4);
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容