# How do I change the radius of circle in a node in tikz style?

I have the following example:

\documentclass[]{beamer}
\usetheme{Darmstadt}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}[>=latex]
\tikzstyle{vertex} = [circle, fill=black!10]
\tikzstyle{selected vertex} = [circle, radius=0.1cm, fill=red!30]
\tikzstyle{nedge} = [-]

\node[vertex] (v1) at (3,0) {v1};
\node[vertex] (v2) at (0,-1) {v2};
\node[vertex] (v3) at (6,-1) {v3};
\draw[nedge] (v1) -- (v2);
\draw[nedge] (v1) -- (v3);
\end{tikzpicture}
\end{frame}
\end{document}


I want to change the radius of vertice in tikz style. How to do it? Thanks for the help.

• Node size can be set with minimum width=2cm Sep 22 at 4:26
• Or minimum radius=2cm? (Did not check) Sep 22 at 5:41
• minimum size should also work, but if you want an exact size you may also need to adjust inner offset (not sure) Sep 22 at 5:46
• @AndrewStacey inner sep Sep 22 at 8:38
• TikZ nodes expand to fit the contents, hence the minimum in minimum size. Setting [inner sep=0pt] will help avoid filling the space. Setting [inner sep=-1cm] would help even more. Sep 22 at 13:28

## 1 Answer

First, don't use tikzstyle which is deprecated, but use tikzset instead. Then, define your nodes as circle with inner sep=0pt (you can also set the outer sep to 0pt), and with a minimum width which is your node diameter.

Finally, you can make other node style inherit a previous one like I did. The selected vertex inherits all parameters from the vertex style, and you can add/replace some afterwards (like the filling here).

\documentclass[]{beamer}
\usetheme{Darmstadt}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\begin{frame}{}
\begin{tikzpicture}[>=latex]
\tikzset
{
vertex/.style={circle, inner sep=0pt, outer sep=0pt, minimum width=1cm,fill=black!10},
selected vertex/.style = {vertex, fill=red!30},
nedge/.style = {-}
}

\node[vertex] (v1) at (3,0) {v1};
\node[vertex] (v2) at (0,-1) {v2};
\node[vertex] (v3) at (6,-1) {v3};
\draw[nedge] (v1) -- (v2);
\draw[nedge] (v1) -- (v3);
\end{tikzpicture}
\end{frame}
\end{document}