下图中两个顶点之间有多条边。但我只能绘制一条边。所以我想标记边的数量。我该怎么做?例如和$3$
之间有边。我该如何标记?$1$
$4$
$3$
\[\begin{tikzpicture}[scale=3, every loop/.style={}]
\vertex[fill] (1) at (.5, 1) [label=above: 1] {};
\vertex [fill](2) at (0,.5) [label=left: 2] {};
\vertex[fill] (3) at (.5,0) [label=above: 3]{};
\vertex[fill] (4) at (1,0) [label=above: 4] {};
\vertex[fill] (5) at (1.5, 0.5) [label=right: 5] {};
\vertex [fill](6) at (1,1) [label=left: 6] {};
\draw (1,1) to[in=-50,out=-130,loop] (1,1);
\path
(1) edge (4)
(1) edge (4)
(1) edge (4)
(1) edge (2)
(2) edge (4)
(2) edge (5)
(3) edge (5)
(3) edge (6)
;
\end{tikzpicture}\]
答案1
您可能正在寻找以下内容:
由于您没有提供完整的小文档来说明是什么信息\vertex
,我重建了自己的代码,希望它与您想要的类似。在这方面我做了一些重要的改变:
- 删除
scale
并相应地乘以每个坐标 - 减小边缘标签的字体大小
定义标签的位置,使它们不重叠
\documentclass[12pt,tikz, margin=3mm]{standalone} \usetikzlibrary{arrows.meta, quotes} \begin{document} \begin{tikzpicture}[ vertex/.style = {circle, fill, inner sep=2pt, outer sep=0pt}, every edge quotes/.style = {auto=left, sloped, font=\scriptsize, inner sep=1pt} ] \node[vertex] (1) at (1.5,3) [label=above: 1] {}; \node[vertex] (2) at (0,1.5) [label=left: 2] {}; \node[vertex] (3) at (1.5,0) [label=left: 3] {}; \node[vertex] (4) at (3,0) [label=right: 4] {}; \node[vertex] (5) at (4.5,1.5) [label=right: 5] {}; \node[vertex] (6) at (3,3) [label=above: 6] {}; % \path (1) edge [pos=.35, "a"] (4) (1) edge ["b"] (2) (2) edge ["c"] (4) (2) edge [pos=.35, "d"] (5) (3) edge [in=-50,out=-130, looseness=12] (3) (3) edge ["e"] (5) (3) edge [pos=.75, "f"] (6); \end{tikzpicture} \end{document}
附录:
另一个代码,稍微短一点,使用positioning
库:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta,
positioning,
quotes}
\begin{document}
\begin{tikzpicture}[
node distance = 11mm and 11mm,
dot/.style = {circle, fill, inner sep=2pt, outer sep=0pt,
label=#1, node contents={}},
every edge quotes/.style = {auto=left, sloped, font=\scriptsize, inner sep=1pt}
]
\node (1) [dot=above:1];
\node (2) [dot= left:2, below left=of 1];
\node (3) [dot= left:3, below right=of 2];
\node (4) [dot=right:4, right=of 3];
\node (5) [dot=right:5, above right=of 4];
\node (6) [dot=above:6, above left=of 5];
%
\path (1) edge [pos=.35, "a"] (4)
(1) edge ["b"] (2)
(2) edge ["c"] (4)
(2) edge [pos=.35, "d"] (5)
(3) edge [in=-50,out=-130, looseness=12] (3)
(3) edge ["e"] (5)
(3) edge [pos=.75, "f"] (6);
\end{tikzpicture}
\end{document}