# Circular graph with many nodes

I have a simple circular graph with N nodes. However N could be arbitrarily large, so I use an ellipsis between nodes. I use the following code:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage[greek,english]{babel}
\usepackage{graphicx}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, positioning, calc}

\definecolor{lavander}{cmyk}{0,0.48,0,0}
\definecolor{violet}{cmyk}{0.79,0.88,0,0}
\definecolor{burntorange}{cmyk}{0,0.52,1,0}
\def\lav{lavander!90}
\def\oran{orange!30}

\begin{document}

\tikzset{%
peer/.style={draw,circle,violet,bottom color=red, top color= white, text=violet, minimum width=25pt},
superpeer/.style={draw, circle,  left color=burntorange, text=violet, minimum width=25pt},
point/.style = {fill=black,inner sep=1pt, circle, minimum width=5pt,align=right,rotate=60},
forward edge/.style={->, >=stealth, shorten >=0pt, thick, color=blue},
}

\def \n {8}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick]
\node[superpeer] (A) at ({360/\n * (1 - 1)}:3.5){$0$};
\node[peer]         (B)  at ({360/\n * (2 - 1)}:3.5){$1$};
\node[peer]         (C)  at ({360/\n * (3 - 1)}:3.5){$2$};
\node[peer]         (D)   at ({360/\n * (4 - 1)}:2.5){$3$};
\node[point] (p1)  at ({360/\n * (4.5 - 1)}:2.5){};
\node[point] (p2)  at ({360/\n * (4.6- 1)}:2.5){};
\node[point] (p3)  at ({360/\n * (4.7 - 1)}:2.5){};
\node[peer] (E) at ({360/\n * (7 - 1)}:3.5) {$N$};
\path (A) edge [color=blue, bend right=20, above, sloped] node[]{$\lambda_{01}, \mu_{01}$} (B);
\path (B) edge [color=blue, bend right=20, above, sloped] node[]   {$\lambda_{12}, \mu_{12}$} (C);
\path (C) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{23}, \mu_{23}$}(D);
\path (A) edge [color=blue, bend left=20, above, sloped] node[]{$\lambda_{0N}, \mu_{0N}$} (E);
\path (B) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{10}, \mu_{10}$}(A);
\path (C) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{21}, \mu_{21}$}(B);
\path (D) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{32}, \mu_{32}$}(C);
\path (E) edge [color=blue, bend right=20, below, sloped] node[] {$\lambda_{{N-1},N}, \mu_{{N-1},N}$}(A);
\end{tikzpicture}

\end{document}


The result however is not great. The circle is hardly symmetrical, and the ellipsis are a sore spot by themselves. Can someone aid me in "professionalising! this figure? Thanks!

-
In its current form your example does not compile for me as it seems ti require some TikZ libraries. Could you please expand your code to a full minimal working example (MWE)? This would lower the barrier to work with your code and therefore increase chances a lot that someone is willing to help you find a solution. Also at least an image of the current output would be nice to see how it looks like at the moment. –  Benedikt Bauer Feb 17 at 17:41
@BenediktBauer: I have managed to give a MWE. Thanks! –  Bravo Feb 17 at 18:00
This example is far from minimal. Your color definitions and most of your options are not necessary for your problem. Also in the first edge the node is missing a closed bracket. That's why this does not compile. –  papabravo Feb 17 at 18:06

## 2 Answers

An solution based on your code. This could serves as a starting point for further simplification of your code. The unsymmetrical comes from the fact that \n=8 defined in the code, but insufficient points (only 5) were given. The correction is to add extra points A1,B1 and C1 and assign their locations properly. This solution also suggests foreach loop to simplify the code.

Code

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage[greek,english]{babel}
\usepackage{graphicx}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, positioning, calc}

\definecolor{lavander}{cmyk}{0,0.48,0,0}
\definecolor{violet}{cmyk}{0.79,0.88,0,0}
\definecolor{burntorange}{cmyk}{0,0.52,1,0}
\def\lav{lavander!90}
\def\oran{orange!30}

\begin{document}

\tikzset{%
peer/.style={draw,circle,violet,bottom color=red, top color= white, text=violet, minimum width=25pt},
superpeer/.style={draw, circle,  left color=burntorange, text=violet, minimum width=25pt},
point/.style = {fill=black,inner sep=1pt, circle, minimum width=5pt,align=right,rotate=60},
%   forward edge/.style={->, >=stealth, shorten >=0pt, thick, color=blue},
}

\def \n {8}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick]
\node[superpeer]    (A)   at ({360/\n * (1 - 1)}:2.5){$3$};
\node[peer]         (B)   at ({360/\n * (2 - 1)}:2.5){$2$};
\node[peer]         (C)   at ({360/\n * (3 - 1)}:2.5){$1$};
\node[peer]         (D)   at ({360/\n * (4 - 1)}:2.5){$N$};
\node[peer]         (E)   at ({360/\n * (5 - 1)}:2.5){$7$};
\node[peer]         (A1)  at ({360/\n * (6 - 1)}:2.5){$6$};
\node[peer]         (B1)  at ({360/\n * (7 - 1)}:2.5){$5$};
\node[peer]         (C1)  at ({360/\n * (8 - 1)}:2.5){$4$};
\node[point] (p1)  at ({360/\n * (4.4 - 1)}:2.5){};
\node[point] (p2)  at ({360/\n * (4.5 - 1)}:2.5){};
\node[point] (p3)  at ({360/\n * (4.6 - 1)}:2.5){};

\path (A) edge [color=blue, bend right=20, above, sloped] node[]{$\lambda_{23}, \mu_{23}$} (B);
\path (B) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{32}, \mu_{32}$}(A);

\path (B) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{21}, \mu_{21}$} (C);
\path (C) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{12}, \mu_{12}$}(B);

\path (C) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{N1}, \mu_{N1}$}(D);
\path (D) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{N1}, \mu_{N1}$}(C);

\path (A1) edge [color=blue, bend right=20, above, sloped] node[]{$\lambda_{67}, \mu_{67}$} (E);
\path (E) edge [color=blue, bend right=20, below, sloped] node[] {$\lambda_{76}, \mu_{76}$}(A1);

\path (A) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{34}, \mu_{34}$} (C1);
\path (C1) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{43}, \mu_{43}$}(A);

\path (A1) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{65}, \mu_{65}$} (B1);
\path (B1) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{56}, \mu_{56}$}(A1);

\path (C1) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{45}, \mu_{45}$}(B1);
\path (B1) edge [color=blue, bend right=20, above, sloped] node[] {$\lambda_{54}, \mu_{54}$}(C1);
\end{tikzpicture}

\end{document}


Edit: Simplified code via foreach loop

\documentclass[border=10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage[greek,english]{babel}
\usepackage{graphicx}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows, automata, positioning, calc}

\definecolor{lavander}{cmyk}{0,0.48,0,0}
\definecolor{violet}{cmyk}{0.79,0.88,0,0}
\definecolor{burntorange}{cmyk}{0,0.52,1,0}
\def\lav{lavander!90}
\def\oran{orange!30}

\begin{document}

\tikzset{%
peer/.style={draw,circle,violet,bottom color=red, top color= white, text=violet, minimum width=25pt},
superpeer/.style={draw, circle,  left color=burntorange, text=violet, minimum width=25pt},
point/.style = {fill=black,inner sep=1pt, circle, minimum width=5pt,align=right,rotate=60},
%   forward edge/.style={->, >=stealth, shorten >=0pt, thick, color=blue},
}

\def \n {8}

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm, semithick]

\node[peer]          (C)   at ({360/\n * (3 - 1)}:2.5){$1$};
\node[peer]          (B)   at ({360/\n * (2 - 1)}:2.5){$2$};
\node[superpeer]     (A)   at ({360/\n * (1 - 1)}:2.5){$3$};
\node[peer]         (C1)   at ({360/\n * (8 - 1)}:2.5){$4$};
\node[peer]         (B1)   at ({360/\n * (7 - 1)}:2.5){$5$};
\node[peer]         (A1)   at ({360/\n * (6 - 1)}:2.5){$6$};
\node[peer]         (E)    at ({360/\n * (5 - 1)}:2.5){$7$};
\node[peer]         (D)    at ({360/\n * (4 - 1)}:2.5){$N$};

\node[point] (p1)  at ({360/\n * (4.4 - 1)}:2.5){};
\node[point] (p2)  at ({360/\n * (4.5 - 1)}:2.5){};
\node[point] (p3)  at ({360/\n * (4.6 - 1)}:2.5){};

\foreach \s/\e/\f/\t in {D/C/N/1,C/B/1/2,B/A/2/3,A/C1/3/4,C1/B1/4/5,B1/A1/5/6,A1/E/6/7}
{\path (\s) edge [color=blue, bend right=20, above, sloped] node[]{\tiny $\lambda_{\f\t},\mu_{\f\t}$} (\e);
\path (\e) edge [color=blue, bend right=20, above, sloped] node[]{\tiny $\lambda_{\t\f},\mu_{\t\f}$} (\s);
};

\end{tikzpicture}

\end{document}

-
This works well, thank you so much! –  Bravo Feb 18 at 10:11
Thank you too. Bravo. –  Jesse Feb 18 at 10:23

Edit: I misunderstood you. You don't actually want to draw N nodes but draw a general diagram. In this case, the polar coordinate notation (angle:radius) I am using below is your friend and should answer all your questions.

I have a starting point here. (note the size of the example). You just have to add your style options and your specific labels now.

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\def \n {8}

\begin{tikzpicture}
\node (node0) at (0:3) {0};
\def\lasti{0} %fixing bug for older tikz versions
\foreach[
evaluate=\i as \angle using (\i)*360/(\n+1),
remember=\i as \lasti (initialy 0)
] \i in {1,...,\n} {
\node (node\i) at (\angle:3) {\i};
\draw (node\i) edge[<-,bend left=20]
node[pos=0.5,sloped,above] {$\lambda_{\i}$}
(node\lasti);
\draw (node\i) edge[->,bend right=20]
node [pos=0.5,sloped,above] {$\lambda_{\i}$}
(node\lasti);
}
\end{tikzpicture}
\end{document}


-