How to draw "ring-like" graphs?

I want this type of plot. I have use tikz and tkz-berge package and write the code

\documentclass[11pt]{article}

\usepackage{tikz}
\usepackage{tkz-berge}

\begin{document}
\SetVertexNoLabel
\begin{tikzpicture}
\begin{scope}[xshift=12cm]
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\grComplete[RA=2/sin(60)]{10}
\end{scope}
\draw (12,-3) node {A Complete Graph};
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[xshift=12cm]
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\grCycle[prefix=a,RA=2/sin(60)]{10}
\end{scope}
\Edges[color=olive](a1,a5,a9)
\Edges[style={dashed,lightgray}](a7,a2)
\draw (12,-3) node {A Small World Graph};
\end{tikzpicture}
\begin{tikzpicture}
\begin{scope}[xshift=12cm]
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\grEmptyCycle[prefix=a,RA=2/sin(60)]{10}
\end{scope}
\Edges[color=olive](a0,a1,a2,a3)
\draw (12,-3) node {A Random Graph};
\end{tikzpicture}
\end{document}


But I unable get that plot in latex. What this code draws is the following: Moreover I get a warning in overleaf. Any kind of help appriciated. Here messsages from a different member:

• Please write a minimal working example. See link for more details what it means. Jun 16 at 12:39
• Please add to your code, starting with \documentclass. Include all necessary, but remove unecessary, so we can copy & run your code. This one so far can't compile for me. Jun 16 at 13:41
• @MS-SPO I edited. Let me know if any problem arises now. Jun 16 at 13:50
• Your code,identical to the answer in How to add edges to automatically generated graphs produces a regular graph, small world graph, random graph so you've drawn "ring-like" graphs. Are you asking how to produce the same graphs (on 20 vertices). Are you asking about how to get curved edges? Or the arrow below all 3 pictures. It's unclear what, specifically, you want. PS: I get no error messages while running the code,
– DJP
Jun 17 at 2:17

Each arc is obtained through the path attribute perp circle that is defined at the beginning; it draws a circle perpendicular to a reference circle (the black one in the first drawing) and it depends on three arguments which are three previously defined points:

• the first is the point on the reference circle through which the new circle will pass and be perpendicular
• the second is the center of the reference circle
• the third belongs to the new circle (and fixes it).

Remarks

1. When randomness appears in the construction of the blue arcs (i.e. the second and third drawings) arcs of the initial circle are also drawn using the command c arc. For the third drawing, these arcs are controlled by the variable \bound; I set it to 4, but feel free to try smaller values.

2. Among the three drawings, the second is a little bit more difficult I think, since it asks for a mixture of regularity and randomness.

Please note that the output is random for the seond and third drawings.

The code

\documentclass[11pt, border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{math, calc}
\begin{document}

\definecolor{B}{RGB}{13, 68, 170}
\tikzset{%
perp circle/.style args={at #1 to #2 through #3}{%
insert path={%
let
\p1 = ($(#1)!1!90:(#2)$),
\p2 = ($(#1)!.5!(#3)$),
\p3 = ($(\p2)!1!90:(#3)$),
\p4 = (intersection of #1--\p1 and \p2--\p3),
\p5 = ($(#3)-(\p4)$),
\n4 = {veclen(\x5, \y5)}
in (\p4) coordinate (tmpcenter) circle (\n4)
}
},
c arc/.style args={#1:#2:#3}{%
insert path={++(#1:#3) arc (#1:#2:#3)}
}
}
\tikzmath{%
real \r, \dr, \a, \bound;
integer \N;
\r = 2.5;
\dr = \r/30;
\N = 25;
\a = 360/\N;
\bound = 4;
}
\begin{tikzpicture}
\path (0, 0) coordinate (O);
\path[clip] (O) circle (\r +\dr);
\draw (O) circle (\r);
%% hyperbolic lines
\foreach \j [evaluate=\j as \k using {\j+2}] in {1, 2, ..., \N}{%
\filldraw[B] (\k*\a: \r) coordinate (A) circle (\dr);
\path (\j*\a: \r) coordinate (B);
\draw[B, thin] [perp circle={at A to O through B}];
}
\end{tikzpicture}
\begin{tikzpicture}
\path (0, 0) coordinate (O);
\path[clip] (O) circle (\r +\dr);
% \path (O) circle (\r);
%% hyperbolic lines
\tikzmath{%
integer \k, \tmp;
for \j in {1, 2, ..., \N}{%
{%
\filldraw[B] (\j*\a: \r) coordinate (A) circle (\dr);
};
\tmp = int(random(1, \N/2));
if \tmp < 3 then {%
\k = \j +int(random(2, \N/2-2));
} else {%
\k = \j +2;
{% arc of the initial circle
\draw (O) [c arc={{\j*\a}:{(\j+1)*\a}:\r}];
};
};
{%
\path (\k*\a: \r) coordinate (B);
\draw[B, thin] [perp circle={at A to O through B}];
};
};
}
\end{tikzpicture}
\begin{tikzpicture}
\path (0, 0) coordinate (O);
\path[clip] (O) circle (\r +\dr);
% \path (O) circle (\r);
%% hyperbolic lines
\foreach \j [evaluate=\j as \k using {\j +int(random(2, \N/2-1))}]
in {1, 2, ..., \N}{%
\filldraw[B] (\j*\a: \r) coordinate (A) circle (\dr);
\path (\k*\a: \r) coordinate (B);
\draw[B, thin] [perp circle={at A to O through B}];
\tikzmath{% arc of the initial circle
if \k-\j==\bound then {%
{%
\draw (O) [c arc={{\j*\a}:{(\j+1)*\a}:\r}];
};
} else {};
}
}
\end{tikzpicture}

• Thank you very much! That's what I looking for! Jun 19 at 2:25
• Can I remove small portion of arc from the black circle? Jun 19 at 2:32
• I don't understand your question. Do you want to remove randomly an arc from the initial black circle? Do yu want to remove a given arc, or some well-defined arcs from it? Are they defined by some of the blue points? If yes, which ones? In general, an example might be useful even if you describe it only with, say, 8 points, or 9... Jun 19 at 8:47
• Now, I've noticed that there are arcs missing form the initial circle in the third figure. But I cannot figure out the rules that make them disappear. Jun 19 at 8:50
• Instead of drawing a circle, if you just draw the vertices, and connect them randomly, I think that would solve the problem. Jun 19 at 15:31

Unless your graph is a well known graph or has just a few edges there isn't an easy way to produce many graphs quickly because the specific edges have to be included one by one. For 20 vertices I can only give you a general flow for how to do it, the more details you expect (such as curved edges) the more complicated and time consuming it will become. Luckily, there is another tool to make things easier. The code that you had include has the first graph as a well known graph (a circulant). The second graph just added some edges to a cycle, and the third, in order to avoid specifying lots of edges, just added a few and called it a random graph. For 20 vertices, the Sage CAS can help. Sage knows lots of graphs and has lots of tools for working with them. Start with the code below:

\documentclass[border={2mm 2mm 8mm 8mm}]{standalone}
\usepackage{sagetex}
\usepackage{tikz,tkz-graph,tkz-berge}
\begin{document}
\begin{sagesilent}
G = graphs.CirculantGraph(20,[1,2])
G.set_pos(G.layout_circular())
G.set_latex_options(scale=3, tkz_style = 'Custom',vertex_size = 0.3,    edge_thickness = 0.02, edge_color = 'blue',vertex_labels=True)
\end{sagesilent}
\begin{tikzpicture}
\sage{G}
\end{tikzpicture}
\end{document}


The output is: This gives us labelled vertices so we have an idea of edges to remove from the circulant. The actual code for it to look like your output is:

\documentclass[border={2mm 2mm 8mm 8mm}]{standalone}
\usepackage{sagetex}
\usepackage{tikz,tkz-graph,tkz-berge}
\begin{document}
\begin{sagesilent}
G = graphs.CirculantGraph(20,[1,2])
G.set_latex_options(scale=3)
\end{sagesilent}
\begin{tikzpicture}
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\tikzset{EdgeStyle/.append style = {color = olive, line width=1pt}}
\sage{G}
\end{tikzpicture}
\end{document}


The output is:

After deciding edges that need to be removed or added, you can create your second graph:

\documentclass[border={2mm 2mm 8mm 8mm}]{standalone}
\usepackage{sagetex}
\usepackage{tikz,tkz-graph,tkz-berge}
\begin{document}
\begin{sagesilent}
G = graphs.CirculantGraph(20,[1,2])
G.set_latex_options(scale=3)
G.delete_edge(2,3)
\end{sagesilent}
\begin{tikzpicture}
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\tikzset{EdgeStyle/.append style = {color = olive, line width=1pt}}
\sage{G}
\end{tikzpicture}
\end{document}


The output is:

Finally, to really get graphs that are constructed randomly, see Sage documentation here. Sample code:

\documentclass[border={2mm 2mm 8mm 8mm}]{standalone}
\usepackage{sagetex}
\usepackage{tikz,tkz-graph,tkz-berge}
\begin{document}
\begin{sagesilent}
G = graphs.RandomGNM(20, 10)
G.set_latex_options(scale=3)
G.set_pos(G.layout_circular())
\end{sagesilent}
\begin{tikzpicture}
\GraphInit[vstyle=Art]
\SetGraphArtColor{red}{olive}
\tikzset{EdgeStyle/.append style = {color = olive, line width=1pt}}
\sage{G}
\end{tikzpicture}
\end{document}


The output is:

Sage is not a part of your LaTeX distribution. The easiest way to experiment is to open a free Cocalc account. Create a LaTeX document in Cocalc, copy/paste the sample code, press Build. Then experiment and read the documentation for more nuanced issues.