具有分割 $IJ$ 和 $JI$ 的图

具有分割 $IJ$ 和 $JI$ 的图

我正在尝试绘制下图来表示二分图: 插图 按照我做的代码:

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[
 node distance = 7mm and 21mm,
 start chain = going below,
 U/.style = {circle, draw, fill=#1,
 inner sep=0pt, minimum size=3mm, 
 node contents={}},
 V/.style = {U, on chain},
 every edge/.style = {decoration={markings,
 mark=at position .5 with {\arrow{Straight Barb}}},
 draw, postaction={decorate}
 },
 ]
 % vertices
 \foreach \i [count=\j from 0] in {1,2,3}%
 {
 \node (n1\j) [V,label=left:{$y_{\i}$}];
 \node (n2\j) [U,above right=of n1\j, label=right:{$z_{\j}$}];
 }
\node (n23) [U,right=of n12, label=right:{$z_{3}$}];
\node (n13) [on chain]      {$\vdots$};
\node (n24) [right=of n13]  {$\vdots$};
\node (n14) [V,label=left:{$y_{t}$}];
\node (n25) [U,right=of n14, label=right:{$z_{t}$}];
% Set I
\node [fit=(n10) (n13),label=above:$I-J$] {};
% Set S-I
\node [fit=(n20) (n23),label=above:$J-I$] {};
% connections 
\foreach \i [count=\j from 0] in {1,2,3}%
{
\draw
(n1\j) edge (n2\i);
}
\draw   (n14) edge (n25);
\end{tikzpicture}
\end{document}

答案1

为了锻炼……

\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                chains,
                decorations.markings,
                fit,
                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, postaction={decorate}
                 },
every edge/.append style = {very thick, dotted, shorten <=3mm, shorten >=3mm}
                    ]
% vertices
\foreach \i [count=\j] in {1,2,3,n}%
    {\ifnum\j=3 
        \node (m\j) [doc,fill=none];
     \else 
        \node (m\j) [doc,label=left:{$y_{\i}$}];
        \node (n\j) [dot, right=of m\j, label=right:{$z_{\i}$}];
     \draw[->-] (m\j) -- (n\j);
     \fi
     }
\draw   (m2) edge (m4)  (n2) edge (n4);
\node[FIT=(m1) (m4), label=$J-I$] {};
\node[FIT=(n1) (n4), label=$I-J$] {};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容