图中顶点标记的位置

图中顶点标记的位置

梅威瑟:

\documentclass[10pt]{article}
\usepackage{pgf,tikz,pgfplots}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\begin{document}
    \begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
    \draw [line width=1pt] (0,0)-- (0,4);
    \draw [line width=1pt] (0,0)-- (4,0);
    \draw [line width=1pt] (0,4)-- (4,4);
    \draw [line width=1pt] (4,4)-- (4,0);
    \draw [line width=1pt] (4,0)-- (10,0);
    \draw [line width=1pt] (10,0)-- (10,4);
    \draw [line width=1pt] (10,4)-- (7,2);
    \begin{scriptsize}
    \draw [fill=black] (0,0) circle (2pt);
    \draw[color=black] (0.16,0.4) node {$V_2$};
    \draw [fill=black] (0,4) circle (2.5pt);
    \draw[color=black] (0.16,4.44) node {$V_1$};
    \draw [fill=black] (4,0) circle (2.5pt);
    \draw[color=black] (4.16,0.44) node {$V_3$};
    \draw [fill=black] (4,4) circle (2.5pt);
    \draw[color=black] (4.16,4.44) node {$V_4$};
    \draw [fill=black] (10,0) circle (2.5pt);
    \draw[color=black] (10.16,0.44) node {$V_5$};
    \draw [fill=black] (10,4) circle (2.5pt);
    \draw[color=black] (10.16,4.44) node {$V_6$};
    \draw [fill=black] (7,2) circle (2.5pt);
    \draw[color=black] (7.16,2.44) node {$V_7$};
    \draw[color=black] (0.38,2.24) node {$$};
    \draw[color=black] (2.08,-0.08) node {$$};
    \draw[color=black] (2.08,3.92) node {$$};
    \draw[color=black] (3.76,2.24) node {$$};
    \draw[color=black] (7.08,-0.08) node {$$};
    \draw[color=black] (10.4,2.24) node {$$};
    \draw[color=black] (8.4,3.5) node {$$};
    \end{scriptsize}
    \end{tikzpicture}
\end{document}

问题:

(1)图形的边宽不同。我该如何修复?

(2)我想在侧面下方标记 V2、V3 和 V5。我该怎么做?

(3)如何指明每一边的方向?

答案1

像这样(你的问题不清楚边缘方向):

在此处输入图片描述

\documentclass[10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{mathrsfs}

\begin{document}
\pagestyle{empty}
    \begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=2pt,
              node contents={}},
every label/.append style = {font=\footnotesize},  
every edge/.style ={draw, line width=1pt, -triangle 45}
                        ]
%
\path  (0,4)   node (v1) [dot, label=above: $V_1$]
       (0,0)   node (v2) [dot, label=below: $V_2$]
       (4,0)   node (v3) [dot, label=below: $V_3$]
       (4,4)   node (v4) [dot, label=above: $V_4$]
       (10,0)  node (v5) [dot, label=below: $V_5$]
       (10,4)  node (v6) [dot, label=above: $V_6$]
       (7,2)   node (v7) [dot, label=above: $V_7$];
%
\path   (v1)    edge (v2) 
        (v2)    edge (v3)
        (v3)    edge (v4)
        (v4)    edge (v1)
        (v3)    edge (v5)
        (v5)    edge (v6)
        (v6)    edge (v7);
    \end{tikzpicture}
\end{document}

编辑: 根据您的评论:

在此处输入图片描述

为此,您只需要在行中添加路径代码(v2) edge[bend left] (v1),即:

\path   (v1)    edge (v2)
        (v2)    edge[bend left] (v1) % added
        (v2)    edge (v3)
        (v3)    edge (v4)
        (v4)    edge (v1)
        (v3)    edge (v5)
        (v5)    edge (v6)
        (v6)    edge (v7);

相关内容