This solution automatically finds the point on the border of two rounded rectangles that connect these nodes by a line that is shifted to the left.
Use key shift between rounded corners=<length> with an optional value (default: 4pt).
For this to work best, the following must be considered
- both nodes are of the shape rounded rectangle
- the
<length> must not be too big so that
- it can at least one intersection point
- it should not find one than more connection point
Every rounded corners stores away the \radius, the \halfarcangle as well as the \outer xsep. We can retrieve them by using the PGF-internal macros \pgf@sh@s@rounded rectangle and \pgf@sh@ma@<node name>.
We then use these values to do the path again (\pgf@sh@bg@rounded rectangle), however we don't use the exact original one but one on the outside of the border – just like all the anchors we would use with normal connections.
However, since we do not want to find the point of the border between the center and the other node we need to find these intersections ourselves.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{automata, arrows.meta, positioning, shapes.misc, intersections}
\makeatletter
\tikzset{
@insert rounded rectangle path/.code=% #1 = node name
\pgfsettransform{\csname pgf@sh@nt@#1\endcsname}%
\csname pgf@sh@s@rounded rectangle\endcsname
\csname pgf@sh@ma@#1\endcsname
\expandafter\def\expandafter\roundedrectanglepoints\expandafter{\roundedrectanglepoints
\pgfmathsetlengthmacro\radius{\radius+\outerxsep}%
\pgfmathsetlengthmacro\arcwidth{\arcwidth+\outerxsep}%
\pgfmathsetlengthmacro\halfheight{\halfheight+\outerysep}%
\pgfmathsetlengthmacro\halfwidth{\halfwidth+\outerxsep}%
\def\outerxsep{0pt}\def\outerysep{0pt}}%
\pgf@sh@savedpoints
\pgftransformshift{\pgfpointanchor{#1}{center}}%
\csname pgf@sh@bg@rounded rectangle\endcsname}
\makeatother
\tikzset{
shift between rounded corners/.default=4pt,
shift between rounded corners/.style={%
% this assumes both nodes to be rounded corners
% this assumes that \tikztostart and \tikztotarget
% are actually node names and no other coordinates
%
% #1 = shift to the left
% must be small enough so that the connection even hits the nodes
% with arc lengths > 180, more than one intersection
% exist which will lead to the wrong point to be found
/utils/exec={%
\pgfinterruptpath
\path[name path=@pathofstart,@insert rounded rectangle path=\tikztostart];
\path[name path=@pathoftarget,@insert rounded rectangle path=\tikztotarget];
\path[name path=@pathofstraight]\pgfextra
\pgfmathanglebetweenpoints{\pgfpointanchor{\tikztostart}{center}}{\pgfpointanchor{\tikztotarget}{center}}%
\pgftransformshift{\pgfpointanchor{\tikztostart}{center}}%
\pgftransformrotate{\pgfmathresult}%
\pgfpathmoveto{\pgfpoint{0}{#1}}%
\pgfpathlineto{\pgfpointadd{\pgfpointanchor{\tikztotarget}{center}}{\pgfpoint{0}{#1}}}%
\endpgfextra;
\tikzset{
name intersections={of=@pathofstart and @pathofstraight, by={@start}},
name intersections={of=@pathoftarget and @pathofstraight, by={@target}}}
\endpgfinterruptpath
},
to path={(@start) -- (@target) \tikztonodes}}}
\begin{document}
\begin{tikzpicture}[
>={Stealth[round]}, line width=0.8pt,
state/.style={draw, rounded rectangle, line width=0.4pt},
]
\node [state] (q1) {$\lbrace q_2,q_3,q_4,q_5,q_7,q_8,q_9 \rbrace$};
\node [state, right=2cm of q1] (q2) {$\lbrace q_2,q_3,q_5,q_6,q_7 \rbrace$};
\path [->]
(q1) edge[shift between rounded corners] node [above, pos = 0.5] {$1$} (q2)
(q2) edge[shift between rounded corners] node [below, pos = 0.5] {$0$} (q1);
\end{tikzpicture}
\begin{tikzpicture}[
>={Stealth[round]}, line width=0.8pt,
state/.style={draw, rounded rectangle, line width=0.4pt, rounded rectangle east arc=concave},
]
\node [state, rotate=-55] (q1) {$\lbrace q_2,q_3,q_4,q_5,q_7,q_8,q_9 \rbrace$};
\node [state, rotate=-80, below right=2cm of q1] (q2) {$\lbrace q_2,q_3,q_5,q_6,q_7 \rbrace$};
\path [->]
(q1) edge[shift between rounded corners] node [above, pos = 0.5] {$1$} (q2)
(q2) edge[shift between rounded corners] node [below, pos = 0.5] {$0$} (q1);
\end{tikzpicture}
\end{document}
Output

second picture
q1and go horizontal to the border ofq2but above(or below) center line? For this you need eg. theintersectionlibrary ortikz-cd. What is yourshortenfor? – hpekristiansen Aug 19 '22 at 17:48