绘制具有小顶点的图形

绘制具有小顶点的图形

我使用 tikz 绘制了如下有向图 -

 \begin{tikzpicture}[roundnode/.style={circle, draw=black!60, very thick,minimum size=4mm}]
            %Nodes
            \node[roundnode]      (u1)                     {$u_1$};
            \node[roundnode]      (u2)       [right=of u1] {$u_2$};
            \node[roundnode]      (u3)       [below right=of u2] {$u_3$};
            \node[roundnode]      (u4)       [below left =of u3] {$u_4$};
            \node[roundnode]      (u5)       [left =of u4] {$u_5$};
            \node[roundnode]      (u6)       [below left =of u1] {$u_6$};

            %Lines
            \draw[->] (u2) -- (u5);
            \draw[->] (u2) -- (u6);
            \draw[->] (u3) -- (u5);
            \draw[->] (u3) -- (u6);
            \draw[->] (u4) -- (u5);
            \draw[->] (u4) -- (u6); 
          \end{tikzpicture}

这给出

在此处输入图片描述

但是我希望节点是小点,顶点标记在它旁边。

有人可以帮我弄这个吗?

谢谢。

答案1

像这样?

在此处输入图片描述

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning, fit}

\begin{document}
\begin{tikzpicture}[roundnode/.style={circle, fill=black!60, inner sep=0pt, minimum size=4mm}]

    \foreach \i [count=\ni] in {120, 60, ..., -180}
        \node[roundnode, label=\i:{$u_\ni$}] at (\i:2cm) (u\ni) {};

            %Lines
            \draw[->] (u2) -- (u5);
            \draw[->] (u2) -- (u6);
            \draw[->] (u3) -- (u5);
            \draw[->] (u3) -- (u6);
            \draw[->] (u4) -- (u5);
            \draw[->] (u4) -- (u6); 
          \end{tikzpicture}
\end{document}

答案2

例如,您可以使用minimum size=<...>。标签定位您可以处理 wir label={north:$u_1$}/南、东、西或西南等。

或者,您也可以使用\node[circle,fill,inner sep=1pt,label={north west:$u_1$}] (u1) {};或 作为序言中的样式\tikzstyle{every node}=[draw,shape=circle,fill,inner sep=1pt]

在此处输入图片描述

梅威瑟:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}

\begin{tikzpicture}[roundnode/.style={draw,shape=circle,fill=blue,minimum size=1mm}]
        %Nodes
        \node[circle,fill,inner sep=1pt,label={north west:$u_1$}]      (u1)                     {};
            \node[roundnode,label={north east:$u_2$}]      (u2)       [right=of u1] {};
            \node[roundnode,label={east:$u_3$}]      (u3)       [below right=of u2] {};
            \node[roundnode,label={south east:$u_4$}]      (u4)       [below left =of u3] {};
            \node[roundnode,label={south west:$u_5$}]      (u5)       [left =of u4] {};
            \node[roundnode, label={west:$u_6$}]      (u6)       [below left =of u1] {};
            %Lines
            \draw[->] (u2) -- (u5);
            \draw[->] (u2) -- (u6);
            \draw[->] (u3) -- (u5);
            \draw[->] (u3) -- (u6);
            \draw[->] (u4) -- (u5);
            \draw[->] (u4) -- (u6); 
          \end{tikzpicture}
\end{document}

相关内容