0

How can I make the edges between the vertices {q_1,q_3} and {q_1,q_2,q_3} parallel?

Code:

\documentclass[tikz,12pt,border=1mm]{standalone}
\usepackage[brazil]{babel}
\usepackage{tkz-euclide}
\usepackage{amssymb}
\usetikzlibrary{automata, positioning, arrows}

\tikzset{->, >=stealth, node distance = 3cm, every state/.style={thick, fill=gray!10}, initial text = $I$, auto rotate/.style={auto=right,->, to path={let \p1=(\tikztostart),\p2=(\tikztotarget), \n1={atan2(\y2-\y1,\x2-\x1)},\n2={\n1-10},\n3={\n1+190} in (\tikztostart.\n2) -- (\tikztotarget.\n3) \tikztonodes}}}

\begin{document} \begin{tikzpicture}[ ->, >=stealth, node distance=3cm, every state/.style={thick, fill=gray!10}, initial text={$I$}, ]

\node[xscale=2, transform shape,state,accepting] (Q2) at (6.5,-3) {% \scalebox{0.5}[1]{${q_1,q_2,q_3}$}}; \node[xscale=2, transform shape,state] (Q4) at (3,-3) {% \scalebox{0.5}[1]{${q_1,q_3}$}};

\draw (Q2) edge [auto rotate, above] node [pos = 0.5] {$b$} (Q4); \draw (Q4) edge [auto rotate, below] node [pos = 0.5] {$a$} (Q2); \end{tikzpicture} \end{document}

Output:

enter image description here

B612
  • 153
  • 6

1 Answers1

1

One quick workaround is to change the following lines

\draw (Q2) edge [auto rotate, above] node [pos = 0.5] {$b$} (Q4);
\draw (Q4) edge [auto rotate, below] node [pos = 0.5] {$a$} (Q2);

to

\draw (Q2) [transform canvas={yshift=1mm}, shorten <=-0.25pt, shorten >=-0.5pt] edge node [above, pos = 0.5] {$b$} (Q4);
\draw (Q4) [transform canvas={yshift=-1mm}, shorten <=-0.25pt, shorten >=-0.5pt] edge node [below, pos = 0.5] {$a$} (Q2);

in order for lines to remain horizontal. transform canvas offsets an original element whereas shorten extends/shrinks tips depending on an argument.

enter image description here

Celdor
  • 9,058