我希望绘制如下所示的有向图,但更简单:
这是我当前的代码:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
[
roundnode/.style={circle, draw=black, fill=black, thin, minimum size=0.5mm},
]
\node[roundnode] (node1) {};
\node[roundnode] (node2) [right=of node1] {};
\draw[->] (node1.east) -- (node2.west);
\end{tikzpicture}
\end{document}
但我很努力地让顶点变得像图中一样小,而且我不知道如何获取顶点外的标签。
答案1
最小代码:
\documentclass{article}
\usepackage{tikz}
\tikzstyle{vertex}=[circle,fill,draw,inner sep=0pt,minimum size=5pt]
\newcommand{\vertex}{\node[vertex]}
\begin{document}
\begin{tikzpicture}
\vertex (a) at (30:1) [label=right:$5$]{};
\vertex (a1) at (90:1) [label=above:$1$]{};
\vertex (a2) at (150:1) [label=left:$2$]{};
\vertex (a3) at (210:.7) [label=below:$3$]{};
\vertex (a4) at (330:.7) [label=below:$4$]{};
\path [->,>=latex,shorten >=0.2]
(a1) edge node[above]{D} (a2)
(a) edge (a1)
(a) edge (a3)
(a1) edge (a3)
(a1) edge (a4)
(a2) edge (a)
(a2) edge (a3)
(a2) edge (a4)
(a4) edge (a3)
;
\end{tikzpicture}
\end{document}
输出:
編輯2:上面的代码
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[vertex/.style={circle,fill,draw,inner sep=0pt,minimum size=5pt}]
\node [vertex] (a) at (30:1) [label=right:$5$]{};
\node [vertex] (a1) at (90:1) [label=above:$1$]{};
\node [vertex] (a2) at (150:1) [label=left:$2$]{};
\node [vertex] (a3) at (210:.7) [label=below:$3$]{};
\node [vertex] (a4) at (330:.7) [label=below:$4$]{};
\path [->,>=latex,shorten >=0.2]
(a1) edge node[above]{D} (a2)
(a) edge (a1)
(a) edge (a3)
(a1) edge (a3)
(a1) edge (a4)
(a2) edge (a)
(a2) edge (a3)
(a2) edge (a4)
(a4) edge (a3)
;
\end{tikzpicture}
\end{document}
编辑1:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[Ahmadi/.style={circle,fill,draw,inner sep=0pt,minimum size=3pt}]
\node [Ahmadi](b) at (0,0) {};
\node [Ahmadi](b1) at (1,0) {};
\node [Ahmadi](b4) at (3.5,0) {};
\node (b2) at (2,0)[right]{$\dots$};
\node (b3) at (2.5,0){};
\path [->,>=latex,shorten >=0.1]
(b) edge (b1)
(b1) edge (b2)
(b3) edge (b4)
;
\end{tikzpicture}
\end{document}
输出
答案2
您可以使用一些图形绘制库来完成此类操作,但这非常简单,因此您无需任何库就可以轻松完成。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\path[every edge/.style={-latex,thick,draw}] foreach \X in {1,...,5}
{(18+\X*72:1.2) node[circle,inner
sep=1.5pt,fill,label={[anchor=18+\X*72+180]18+\X*72:\X}](p\X){}}
(p1) edge (p2) edge (p3) edge (p4)
(p2) edge (p3) edge (p4) edge (p5)
(p5) edge (p1) edge (p3)
(p4) edge (p3)
(126:1.4) node{$D$} ;
\end{tikzpicture}
\end{document}