# Drawing a wheel graph with TikZ

Is there a fast way to add a central vertex connected to all others after drawing the cycle graph using the graph library of the tikz package?

This is what the code currently looks like:

\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]
\end{tikzpicture}
\end{document}

• Please make your code compilable by adding documentclass, \begin{document}, ... – hpekristiansen Sep 17 '20 at 23:11

Give a name to subgraph and then you can use the vertices. Finally find the center of subgraph and draw from center to each vertices.

\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]
\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}


ADDENDUM: According to pgf manual on page 212, you can use mid definition.

\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]
\node at  ($(A 1)!.5!(A 4)$) (C){1};