2

I want to draw e.g. 9,13,17 nodes, evenly, around a circle in TikZ. How do I do this?

Then I also want to be able to edit easily the edges between the different nodes (to represent different graphs on those nodes).

1 Answer 1

4

A very simple approach using polar coordinates. Change the value of \n to adjust the number of circles. The nodes are named was n-<number>

nodes around circle

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=3]
\pgfmathsetmacro\n{9}
\draw(0,0) circle (1);
\foreach \i in {0,...,\n} {
    \pgfmathsetmacro\r{\i*(360/\n)}
    \node (n-\i) at (\r:1) {A};
}
\end{tikzpicture}

\end{document}

More complex example:

complex circle

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[scale=3]
\draw(0,0) circle (1);
\pgfmathsetmacro\n{6}
\foreach \i/\k in {0/A,1/B,2/C,3/X,4/Y,5/Z} {
    \pgfmathsetmacro\r{\i*(360/\n)}
    \fill (\r:1) circle (1pt) coordinate (n-\i);
    \node at (\r:1.2) {\k};
}
\draw (n-0) -- (n-3);
\draw (n-0) -- (n-5);
\draw (n-0) -- (n-2);
\end{tikzpicture}

\end{document}
12
  • OK this is useful to me. But how do I get the nodes as actual black circles, rather than the letter A? Commented Sep 24, 2018 at 16:06
  • I have replaced the "A" with "$\circ$" or "$\bullet$" but that's obviously not the proper way. Commented Sep 24, 2018 at 16:09
  • @GinkgoBiloba: Instead of \node ... {A}; try \node [draw=black, inner sep=1pt] .. {};, where the inner sep will control how big the circle is. Commented Sep 24, 2018 at 17:08
  • \node [fill=black, circle=1pt](n-\i) at (\r:1) {} seems to work but the nodes are too big Commented Sep 24, 2018 at 17:40
  • + How do I start adding edges between the nodes? Commented Sep 24, 2018 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .