绘制带有节点标签的网络图

绘制带有节点标签的网络图

我想绘制一个节点带有标签的图形。我想在它下面为每个节点贴上标签。我想更改以下代码,为节点 5 绘制一个点,在节点下方,我想有 5 个点。

\begin{tikzpicture}[%auto, node distance=1.5cm, every loop/.style={},
                %thick,main node/.style={scale=0.7, 
                %circle,draw,font=\sffamily\small\bfseries}]
                dot/.style={fill,circle, minimum size=5pt,inner sep=0,node contents={}},
   circ/.style={draw, circle, minimum size=10pt,inner sep=0pt, node 
contents={}}]
\node[main node] (5) {5};

\end{tikzpicture}

我想问一下我该怎么做。提前感谢你的帮助。

答案1

定位标签的不同方式 - 如果需要任何补充/澄清,请回复

在此处输入图片描述

\begin{tikzpicture}[
  auto, 
  node distance=1.5cm, 
  every loop/.style={},
  thick,
  main node/.style={scale=0.7, 
                    circle,
                    draw,
                    font=\sffamily\small\bfseries},
  dot/.style={fill,
                circle, 
                minimum size=5pt,
                inner sep=0,
                node contents={}},
  circ/.style={draw, 
                circle, 
                minimum size=10pt,
                inner sep=0pt, 
                node contents={}}
            ]
  \node[main node, label=above:$B$] at (0,0)(5) {5};
    \node[main node, label=below:$B$] at (0,-2)(5) {5};
      \node[main node, label=left:$B$] at (0,-4)(5) {5};
         \node[main node, label=right:$B$]at (0,-6) (5) {5};
    \node [circle,
            thin,
            inner sep=1pt,
            draw=red,
            fill=red!40,
            label={[label distance=1cm]30:$5$}] 
            at (0,-8){};     
  \end{tikzpicture}

相关内容