# How to draw a digraph without intersecting arcs

I am tryng to draw the following figure that is a graph with bipartition $X$ and $Y$:

I'm having trouble drawing arcs so they don't intersect. Follows the my code that alreadys did:

 \begin{tikzpicture}[
node distance = 5mm and 33mm,
start chain = going below,
doc/.style = {
dot,
on chain
},
dot/.style = {circle, fill, inner sep=0pt, outer sep=0pt, minimum size=3mm,
node contents={}},
FIT/.style = {ellipse, draw, thick, inner xsep=2em, yshift=-1ex, fit=#1},
->-/.style = {decoration={markings,
mark=at position .5 with {\arrow{Straight Barb}}},          draw, postaction={decorate}             },
every edge/.append style = {very thick, dotted, shorten <=3mm, shorten >=3mm}
]
% vertices
\foreach \i [count=\j] in {1,2,3,4,5,6,t-1,t}%
{
\ifnum\j=6
\node (m\j) [doc,fill=none];
\else
\node (m\j) [doc,label=left:{$a_{\i}$}];
\node (n\j) [dot, right=of m\j, label=right:{$b_{\i}$}];
\draw[->-, red] (m\j) -- (n\j);
\fi
}

\draw[->-, blue]
(m2) -- (n1);
\draw[->-, blue]
(m1) -- (n2);

\draw[->-, blue]
(n4) -- (m5);
\draw[->-, blue]
(n3) -- (m4);

\draw[->-, blue]
(n3) -- (m4);

\draw[->-, blue]
(n7) -- (m8);

% dashed line
\draw   (m5) edge (m7)  (n5) edge (n7);

\node[FIT=(m1) (m7), label=$X$] {};
\node[FIT=(n1) (n7), label=$Y$] {};
\end{tikzpicture}


For example in my code the arcs $(b_1,a_2)$ and $(b_2,a_1)$ intersects. I wish to draw as shown in the figure. How I can to do?

Like this?

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
chains,
decorations.markings,
fit,
positioning,
shapes.geometric,
}

\begin{document}
\begin{tikzpicture}[
node distance = 5mm and 33mm,
start chain = going below,
doc/.style = {dot, on chain},
dot/.style = {circle, fill,
inner sep=0pt, outer sep=0pt, minimum size=3mm,
node contents={}},
FIT/.style = {ellipse, draw, thick, inner xsep=2em, yshift=-1ex, fit=#1},
->-/.style = {decoration={markings,
mark=at position .5 with {\arrow{Straight Barb}}},
draw=#1, postaction={decorate}             },
->-/.default = red,
every edge/.append style = {very thick, dotted, shorten <=3mm, shorten >=3mm}
]
% vertices
\foreach \i [count=\j] in {1,2,3,4,5,6,t-1,t}%
{
\ifnum\j=6
\node (m\j) [doc,fill=none];
\else
\node (m\j) [doc,label=left:{$a_{\i}$}];
\node (n\j) [dot, right=of m\j, label=right:{$b_{\i}$}];
\draw[->-] (m\j) -- (n\j);
\fi
}
%
\begin{scope}[->-/.append style=blue],
\draw[->-]  (n1) -- (m2);
\draw[->-, semithick, rounded corners=2mm]
(n2.45) -- ([xshift=7mm] n1.south)
|- ([yshift=2mm] n1.north)
-| (m1);
\draw[->-]  (n4) -- (m5);
\draw[->-]  (n3) -- (m4);
\draw[->-, semithick, rounded corners=2mm]
(n5.45) -- ([xshift=7mm] n4.south)
|- ([yshift=2mm] n3.north)
-| (m3);
\draw[->-]  (n7) -- (m8);
\draw[->-, semithick, rounded corners=2mm]
(n8.45) -- ([xshift=11mm] n7.south)
|- ([yshift=2mm] n7.north)
-| (m7);
\end{scope}

% dashed line
\draw   (m5) edge (m7)  (n5) edge (n7);

\node[FIT=(m1) (m7), label=$X$] {};
\node[FIT=(n1) (n7), label=$Y$] {};
\end{tikzpicture}
\end{document}

• I see giant dots at first view :-) Commented Nov 7, 2021 at 22:13
• @Sebastiano, yes. With diameter of 3mm ;-) Commented Nov 7, 2021 at 23:18