在使用绘制循环图后,是否有一种快速的方法可以添加与所有其他顶点相连的中心顶点图形tikz 包的库?
代码目前的样子如下:
\documentclass{article}
\begin{document}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}
\begin{tikzpicture}[scale=0.8,every node/.style={scale=0.8}]
\graph [nodes={circle,fill=black!25}, edges={black!60, semithick}, clockwise, radius=8em,
n=9, p=0.3]
{ subgraph C_n [n=6,m=3,clockwise,radius=2cm] };
\end{tikzpicture}
\end{document}
答案1
给 命名subgraph
,然后就可以使用顶点了。最后找到 的中心subgraph
,并从中心绘制到每个顶点。
\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{graphs,graphs.standard,calc}
\begin{document}
\begin{tikzpicture}[scale=0.8,every node/.style={scale=0.8}]
\graph [nodes={circle,fill=black!25}, edges={black!60, semithick}, clockwise, radius=8em,
n=9, p=0.3]
{ subgraph C_n [n=6,m=3,clockwise,radius=2cm,name=A] };
\node at ($(A 1)!.5!(A 4)$) (C){};
\foreach \i in {1,2,...,6}{
\draw (C)-- (A \i); }
\draw [fill=black!25](C) circle (0.4em);
\end{tikzpicture}
\end{document}
附录:
根据pgf 手册在第 212 页上,您可以使用mid
定义。
\documentclass[tikz,margin=3mm]{standalone}
\usetikzlibrary{graphs,graphs.standard,calc}
\begin{document}
\begin{tikzpicture}[scale=0.8,every node/.style={scale=0.8}]
\graph [empty nodes, nodes={circle,fill=black!25}, edges={black!60, semithick}, clockwise, radius=8em,
n=9, p=0.3]
{ subgraph C_n [n=6,m=3,clockwise,radius=2cm,name=A]-- mid};
\node at ($(A 1)!.5!(A 4)$) (C){1};
\foreach \i [count=\xi from 2] in {1,2,...,6}{
\node at (A \i){\xi}; }
\end{tikzpicture}
\end{document}