enter image description here

This is what I have done

  \tikzstyle{every node}=[circle, fill=black!,inner sep=0pt, minimum width=4pt]
        \node (n_1) at (-1.1,0)[label=left:{\tiny $x^{(3)}_1$}] {};
        \node (n_2) at (1.1,0)[label=right:{\tiny $x^{(3)}_3$}] {};
        \node (n_3) at (-.5,.5)[label=:{\tiny $x^{(2)}_1$}] {};
        \node (n_4) at (-.167, .65)[label=above left:{\tiny $x^{(2)}_3$}] {};
        \node (n_5) at (.167,.65)[label=above right:{\tiny $x^{(2)}_5$}] {};
        \node (n_6) at (.5,.5)[label=above right:{\tiny $x^{(2)}_7$}] {};
        \node (n_7) at (0,1.4)[label=right:{\tiny $x^{(4)}_1$}] {};
        \node (n_8) at (-0.15,2.5)[label=above:{\tiny $x^{(7)}_1$}] {};
        \node (n_9) at (-0.41,2.42)[label=above:{\tiny $x^{(5)}_1$}] {};
        \node (n_{10}) at (-0.65,2.25)[label=above:{\tiny $x^{(3)}_1$}] {};
        \node (n_{11}) at (-0.82,2)[label=above:{\tiny $x^{(1)}_1$}] {};
        \node (n_{12}) at (0.15,2.5)[label=above:{\tiny $x^{(9)}_1$}] {};
        \node (n_{13}) at (0.41,2.42)[label=above:{\tiny $x^{(11)}_1$}] {};
        \node (n_{14}) at (0.65,2.25)[label=above:{\tiny $x^{(13)}_1$}] {};
        \node (n_{15}) at (0.82,2)[label=above:{\tiny $x^{(15)}_1$}] {};
        \foreach \from/\to in
        \draw[thick] (\from) -- (\to);  
  • 1
    I'm afraid that you'll have to draw them manually here. But since we're in the topology area, you could modify your graph a bit to align horizontally the upper nodes and use fit library to vreate a node around them. Same with the (2) level.
    – SebGlav
    May 25, 2021 at 19:41

2 Answers 2


As @SebGlav said, the first line has to be drawn “manually”, the other ones with the fit library.

    \tikzset{Ahmad/.style={circle, fill=black!,inner sep=0pt, minimum width=4pt}}  
    \tikzset{Shahnawaz/.style={draw=red,inner sep=0pt,outer sep=0pt,thick,ellipse, dashed}}     
    \node [Ahmad] (n_1_3) at (-1.1,0)[label=left:{\tiny $x^{(3)}_1$}] {};
    \node [Ahmad] (n_3_3) at (1.1,0)[label=right:{\tiny $x^{(3)}_3$}] {};
    \node [Ahmad] (n_1_2) at (-.5,.5)[label=:{\tiny $x^{(2)}_1$}] {};
    \node [Ahmad] (n_3_2) at (-.167, .65)[label=above left:{\tiny $x^{(2)}_3$}] {};
    \node [Ahmad] (n_5_2) at (.167,.65)[label=above right:{\tiny $x^{(2)}_5$}] {};
    \node [Ahmad] (n_7_2) at (.5,.5)[label=above right:{\tiny $x^{(2)}_7$}] {};
    \node [Ahmad] (n_1_4) at (0,1.4)[label=right:{\tiny $x^{(4)}_1$}] {};
    \node [Ahmad] (n_1_7) at (-0.15,2.5)[label=above:{\tiny $x^{(7)}_1$}] {};
    \node [Ahmad] (n_1_5) at (-0.41,2.42)[label=above:{\tiny $x^{(5)}_1$}] {};
    \node [Ahmad] (n_1_3_2) at (-0.65,2.25)[label=above:{\tiny $x^{(3)}_1$}] {};
    \node [Ahmad] (n_1_1) at (-0.82,2)[label=above:{\tiny $x^{(1)}_1$}] {};
    \node [Ahmad] (n_1_9) at (0.15,2.5)[label=above:{\tiny $x^{(9)}_1$}] {};
    \node [Ahmad] (n_1_11) at (0.41,2.42)[label=above:{\tiny $x^{(11)}_1$}] {};
    \node [Ahmad] (n_1_13) at (0.65,2.25)[label=above:{\tiny $x^{(13)}_1$}] {};
    \node [Ahmad] (n_1_15) at (0.82,2)[label=above:{\tiny $x^{(15)}_1$}] {};
    \foreach \from/\to in
    \draw[thick] (\from) -- (\to);  
    % \node[Shahnawaz, fit=(n_1_1) (n_1_3_2)(n_1_5)] {};
    \draw [thick, red, dashed] ($(n_1_1)+(3pt, -3pt)$) .. controls (n_1_7) and (n_1_9) .. ($(n_1_15)-(3pt, 3pt)$) arc [start angle=225,end angle=405,radius=6pt] node [anchor=west] {$V_1$} .. controls ($(n_1_9)+(0,16pt)$) and ($(n_1_7)+(0,16pt)$) .. ($(n_1_1)+(-3pt, 6pt)$) to [out=225, in=135] ($(n_1_1)-(3pt, 3pt)$) to [out=315, in=225] cycle;
    \node[Shahnawaz, inner sep=10pt,fit=(n_1_2)(n_3_2)(n_5_2)(n_7_2), label={[red]20:$V_2$}] {};
    \node[Shahnawaz, fit=(n_1_3) (n_3_3), inner sep=10pt, label={[red]0:$V_3$}] {};
    \node[Shahnawaz, inner sep=10pt,fit=(n_1_4), label={[red]0:$V_4$}] {};

enter image description here


Another option is to draw arcs around the desired nodes with the help of the calc library. To achieve this, I moved your nodes slightly, to make those of each group lie on the same circumference and on known angles.

This is what I get:

\documentclass {article}       
\usepackage    {tikz}

\tikzstyle{every node}=[circle, fill=black, inner sep=0pt, minimum width=4pt]
% dimensions
\def\tr{1.1} % top radius
\def\br{0.7} % bottom radius
\def\gr{0.2} % group radius
% nodes
\node (n_1)      at (-1.1,0)  [label=left:       {\tiny $x^{(3)}_1$}] {};
\node (n_2)      at  (1.1,0)  [label=right:      {\tiny $x^{(3)}_3$}] {};
\node (n_3)      at  (135:\br)[label=above:      {\tiny $x^{(2)}_1$}] {};
\node (n_4)      at  (105:\br)[label=above left: {\tiny $x^{(2)}_3$}] {};
\node (n_5)      at   (75:\br)[label=above right:{\tiny $x^{(2)}_5$}] {};
\node (n_6)      at   (45:\br)[label=above right:{\tiny $x^{(2)}_7$}] {};
\node (n_7)      at    (0,1.4)[label=right:      {\tiny $x^{(4)}_1$}] {};
  \node (n_8)    at ( 97:\tr) [label=above:      {\tiny $x^{(7)}_1$}] {};
  \node (n_9)    at (111:\tr) [label=above:      {\tiny $x^{(5)}_1$}] {};
  \node (n_{10}) at (125:\tr) [label=above:      {\tiny $x^{(3)}_1$}] {};
  \node (n_{11}) at (139:\tr) [label=above:      {\tiny $x^{(1)}_1$}] {};
  \node (n_{12}) at ( 83:\tr) [label=above:      {\tiny $x^{(9)}_1$}] {};
  \node (n_{13}) at ( 69:\tr) [label=above:      {\tiny $x^{(11)}_1$}]{};
  \node (n_{14}) at ( 55:\tr) [label=above:      {\tiny $x^{(13)}_1$}]{};
  \node (n_{15}) at ( 41:\tr) [label=above:      {\tiny $x^{(15)}_1$}]{};
% edges
\foreach \from/\to in {n_1/n_2,n_1/n_3,n_1/n_4,n_1/n_5,n_1/n_6,n_1/n_7,n_2/n_3,%
  \draw[thick] (\from) -- (\to);
% groups
\draw[red,dashed,thick] ($(n_{11})+(139:\gr)$) arc (139:319:\gr) arc
                        (139:41:\tr-\gr)       arc (221:401:\gr) arc (41:139:\tr+\gr);
\draw[red,dashed,thick] (n_7) circle (\gr);
\draw[red,dashed,thick] ($(n_3)+(135:\gr)$)    arc (135:315:\gr) arc (135:45:\br-\gr)
                                               arc (225:405:\gr) arc (45:135:\br+\gr);
\draw[red,dashed,thick] ($(n_1)+(0,\gr)$)      arc (90:270:\gr) -- ($(n_2)+(0,-\gr)$)
                                               arc (-90:90:\gr) -- cycle;
% group labels
\node[red,fill=none] at ($(n_{15})+(0.3,0)$) [right] {$V_1$};
\node[red,fill=none] at ($(n_6)+(0.3,0)$)    [right] {$V_2$};
\node[red,fill=none] at ($(n_2)+(0.3,0)$)    [right] {$V_3$};
\node[red,fill=none] at ($(n_7)+(0.3,0)$)    [right] {$V_4$};

enter image description here

Edit 1: I changed some distances (the radii, parametrized now) and the scale to avoid some labels overlapping the edges.

Edit 2: Another approach for placing the nodes, labels and lines. Also a little bit more customizable.

\usepackage    {tikz}

% dimensions
\def\tr{3}    % top group radius
\def\br{2}    % bottom group radius
\def\gr{0.6}  % grouping radius
\def\ch{4.5}  % v4 height
\def\sd{3}    % v3 nodes semidistance
\def\nd{0.05} % nodes radius
\def\ld{0.3}  % label distance
% styles
   myline/.style={shorten <= 2*\nd cm, shorten >= 2*\nd cm},
  mygroup/.style={red,dashed,thick,fill=red,fill opacity=0.025}
% coordinates, labels and lines
\coordinate (v3x1) at (-\sd,0);
\coordinate (v3x3) at (\sd,0);
\coordinate (v4x1) at (0,\ch);
\fill (v3x1) circle (\nd);
\fill (v3x3) circle (\nd);
\fill (v4x1) circle (\nd);
\node at ($(v3x1)-(\ld,0)$) {$x_1^{(3)}$};
\node at ($(v3x3)+(\ld,0)$) {$x_3^{(3)}$};
\node at ($(v4x1)+(\ld,0)$) {$x_1^{(4)}$};
\draw[myline] (v3x1) -- (v3x3);
\foreach\i in {1,3,...,15}
{% v1
  \pgfmathsetmacro\j{146-7*\i} % angle
  \coordinate (v1x\i) at ($(v4x1)+(\j:\tr)$);
  \node at ($(v4x1)+(\j:\tr+\ld)$) {$x_1^{(\i)}$};
  \fill (v1x\i) circle (\nd);
  \draw[myline] (v1x\i) -- (v4x1);
\foreach\i in {1,3,5,7}
{% v2
  \pgfmathsetmacro\j{150-15*\i} % angle
  \coordinate (v2x\i) at (\j:\br);
  \ifnum\i < 5
    \node at ($(v2x\i)-(\ld,0)$) {$x_\i^{(2)}$};
    \node at ($(v2x\i)+(\ld,0)$) {$x_\i^{(2)}$};
  \fill (v2x\i) circle (\nd);
  \draw[myline] (v2x\i) -- (v4x1);
  \foreach\l in {1,3}
    \draw[myline] (v2x\i) -- (v3x\l);
% groups
\draw[mygroup] ($(v1x1)+(139:\gr)$) arc (139:319:\gr) arc (139:41:\tr-\gr)
                                    arc (221:401:\gr) arc (41:139:\tr+\gr);
\draw[mygroup] ($(v2x1)+(135:\gr)$) arc (135:315:\gr) arc (135:45:\br-\gr)
                                    arc (225:405:\gr) arc (45:135:\br+\gr);
\draw[mygroup] ($(v3x1)+(0,\gr)$)   arc (90:270:\gr)  --  ($(v3x3)+(0,-\gr)$)
                                    arc (-90:90:\gr)  --  cycle;
\draw[mygroup] (v4x1) circle (\gr);
% groups labels
\node[red] at ($(v1x15)+(-30:\gr)$) [right] {$V_1$};
\node[red] at ($(v2x7) +(45:\gr)$)  [right] {$V_2$};
\node[red] at ($(v3x3) +(0,\gr)$)   [above] {$V_3$};
\node[red] at ($(v4x1) -(\gr,0)$)   [left]  {$V_4$};

enter image description here

  • Thank you for your help. The labels are overlapping with the edges. How to fix this? May 30, 2021 at 6:30
  • @ShahnawazAhmad, you can play with the scale and the distance between nodes to achieve this. Look at my edit. Another option could be changing the label positions or bending some edges too. May 30, 2021 at 8:13

You must log in to answer this question.

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