我如何使用 LaTeX 绘制这个有向图?
我知道以下代码:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}
\tikzgraphsset{declare={polygon_n}{[clique]\foreach\x in\tikzgraphV{\x/}}}
\begin{document}
\begin{center}
\tikz\graph[clockwise, nodes={circle, node distance=4cm, fill=blue, inner sep=1}]
{ polygon_n[n=5] };
\end{center}
\end{document}
谢谢。
答案1
如果不需要旋转subgraph C_n [n=5, counterclockwise]
,可以使用库提供的graphs.standard
来获取基本形状。然后只需设置节点和边的样式,如下例所示:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphs.standard}
\begin{document}
\begin{center}
\begin{tikzpicture}
\graph [
nodes={draw, circle, fill=red!20}, % style of nodes
edges={-latex}, % style of lines between nodes
radius=2cm % size of graph
] {
subgraph C_n [n=5, counterclockwise]
};
\end{tikzpicture}
\end{center}
\end{document}