4

I am struggling to figure out how to make a graph that connects 12 circular nodes in a circle. I have the code:

\begin{tikzpicture}
\graph [nodes={draw, circle}, clockwise, radius=3in, nodes, n=12] {
subgraph C_n [name=outer]
};
\end{tikzpicture}

which gives me this: enter image description here but I would like the edges connecting them to be curved so that it resembles a circle rather than a dodecahedron. Since this issue is similar to anti-clockwise pathed curve for connecting nodes I tried replicating that code, but with 12 nodes instead of four, which gave me a square. The only advantage to this method was that I was able to start the nodes at 0 rather than 1, as I would like to do in my final product.

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,    thick,main node/.style={circle,draw,font=\sffamily\Large\bfseries}]
\node[main node] (1) {0};
\node[main node] (2) [below right of=1] {1};
\node[main node] (3) [below right of=2] {2};
\node[main node] (4) [below right of=3] {3};
\node[main node] (5) [below left of=4] {4};
\node[main node] (6) [below left of=5] {5};
\node[main node] (7) [below left of=6] {6};
\node[main node] (8) [above left of=7] {7};
\node[main node] (9) [above left of=8] {8};
\node[main node] (10) [above left of=9] {9};
\node[main node] (11) [above right of=10] {t};
\node[main node] (12) [above right of=11] {e};

\path[every node/.style={font=\sffamily\small}]
(1) edge [bend right] node[right] {} (2)
(2) edge [bend right] node[right] {} (3)
(3) edge [bend right] node[right] {} (4)
(4) edge [bend right] node[right] {} (5);
(5) edge [bend right] node[right] {} (6)
(6) edge [bend right] node[right] {} (7)
(7) edge [bend right] node[right] {} (8)
(8) edge [bend right] node[right] {} (9);
(9) edge [bend right] node[right] {} (10)
(10) edge [bend right] node[right] {} (11)
(11) edge [bend right] node[right] {} (12)
(12) edge [bend right] node[right] {} (1);
\end{tikzpicture}

enter image description here

Is there a way to make both the nodes and edges circular?

  • 1
    I think polar coordinates to insert nodes is better than relative positioning. – Sigur Feb 14 '18 at 17:20
  • This example does not use the graphdrawing library: tex.stackexchange.com/a/381283 – Ross Feb 14 '18 at 17:49
5

What about:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs, graphs.standard}

\begin{document}

\begin{tikzpicture}
\graph [nodes={draw, circle}, clockwise, radius=3in, nodes, n=12, edge={bend left=12}] {
subgraph C_n [name=outer]
};
\end{tikzpicture}

\end{document}

enter image description here


Edit: after again reading your question, I found that you want to start with 0. So, possibly this is an acceptable solution:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs, graphs.standard}

\begin{document}

\begin{tikzpicture}
\graph [nodes={draw, circle, minimum width=.25in, inner sep=0pt}, clockwise, radius=1in, nodes, n=12, V={0,...,11}, ->, edge={bend left=10,>=stealth}] {
subgraph C_n [name=outer]
};
\end{tikzpicture}

\end{document}

enter image description here

| improve this answer | |
  • In my opinion you could edit your answer and keep only the last solution, which is much better than the others. Good job! – Sigur Feb 14 '18 at 17:43
  • Very nice! (+1) You may benefit by replacing bend=10 by bend=12 in the upper two examples. – user121799 Feb 14 '18 at 17:49
  • @Sigur: I removed the second example, as this was merely the same as the first, just with arrow heads added. marmot: I edited the first example accordingly. Thanks! – Jasper Habicht Feb 14 '18 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.