在图下写

在图下写

请问,有人可以帮我在 LaTeX 中在图表下写出像这样的图表吗:

在此处输入图片描述

此代码

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
\matrix[column sep=4em, row sep=9ex, inner sep=0pt, minimum width=8pt] (M) { & &\node[mypoint, label={above:v$_{3}$}] (V3) {};
&  & & \node[mypoint, label={above:v$_{3}$}] (V31) {};\\
    \node[mypoint, label={[left,xshift=-6pt,yshift=-3pt]v$_{1}$}] (V1) {}; 
    & & \node[mypoint, label={[right,xshift=6pt,yshift=-3pt]v$_{4}$}] (V4) {};
  & \node[mypoint, label={[left,xshift=-6pt,yshift=-3pt]v$_{1}$}] (V11) {};
   & & \node[mypoint, label={[right,xshift=6pt,yshift=-3pt]v$_{4}$}] (V41) {};
    \\
    \node[mypoint, label={[left,xshift=2pt,yshift=4pt]v$_{2}$}] (V2) {}; & & \node[mypoint, label={[right,xshift=6pt,yshift=-3pt]v$_{5}$}] (V5) {};
    & \node[mypoint, label={[left,xshift=2pt,yshift=4pt]v$_{2}$}] (V21) {}; & & \node[mypoint, label={[right,xshift=6pt,yshift=-3pt]v$_{5}$}] (V51) {};\\
};
\draw (V3) --  (V1);
\draw (V1) --  (V4);
\draw (V2) --(V5);
\draw (V11) --  (V31);
\draw (V11) --  (V41);
\draw (V11) --  (V51);

\draw (V21) --  (V41);
\draw (V21) --  (V31);
\draw (V21) --(V51);


\end{tikzpicture} 

    \caption{A bipartite graph \label{19}}

\end{figure}
\end{document}

答案1

对于连接两个节点的边,使用node命令来获取你想要的:

\draw (V2) to node[below] {$G$} (V5);

\draw (V21) to node[below] {$K_{2,3}$} (V51);

如果距离边缘太近,请使用below=5pt(或其他尺寸)将其移得更远。

答案2

像这样?

在此处输入图片描述

我将您的代码重写为更简单、简洁的形式(离题):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{matrix, positioning, quotes} % added tikz libraries

\begin{document}
    \begin{tikzpicture}[
             auto = right,
    node distance = 11mm,
    every matrix/.style = {matrix of nodes,
                      nodes={circle, fill,
                             minimum size=3mm, inner sep=0mm, outer sep=0mm},
                      column sep=4em,
                      row sep=9ex,
                      }
                        ]
\matrix (M1) 
{
                        & |[label=right:$v_3$]|     \\
|[label=left:$v_1$]|    & |[label=right:$v_4$]|     \\
|[label=left:$v_2$]|    & |[label=right:$v_5$]|     \\
};
\draw   (M1-2-1) -- (M1-1-2)
        (M1-2-1) -- (M1-2-2)
        (M1-3-1) to ["$\mathrm{G}$"] (M1-3-2);  % <--
          ]
%
\matrix (M2) [right=of M1]
{
                        & |[label=right:$v_3$]|     \\
|[label=left:$v_1$]|    & |[label=right:$v_4$]|     \\
|[label=left:$v_2$]|    & |[label=right:$v_5$]|     \\
};
\draw   (M2-2-1) -- (M2-1-2)
        (M2-2-1) -- (M2-2-2)
        (M2-2-1) -- (M2-3-2)
        (M2-3-1) -- (M2-1-2)
        (M2-3-1) -- (M2-2-2)
        (M2-3-1) to ["$\mathrm{K}_{2,3}$"] (M2-3-2); % <--
    \end{tikzpicture}
\end{document}

除了您要查找的代码之外,还表示% <---

相关内容