1

How to draw the following graph in my manuscript?

enter image description here

I am unable to draw this graph.

Can someone please me to draw this?

I am new to TikZ. I have started learning from this link https://www.overleaf.com/learn/latex/TikZ_package but unfortunately it does not show how to draw this kind of graph.

Can someone please help?

0

2 Answers 2

2

I took the link from @LokiRagnarok comment and made this.

Its a more manual approach then @zarko answer.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
    \begin{tikzpicture}
    \begin{scope}[every node/.style={circle,thick,draw}]
    \node (0) at (4,4) {0};
    \node (1) at (2,0) {1};
    \node (2) at (6,0) {2};
    \node (3) at (1,0) {3};
    \node (4) at (4,-4) {4};
    \node (5) at (7,0) {5} ;
    \node (6) at (0,0) {6} ;
    \node (7) at (8,0) {7} ;
    \end{scope}

    \begin{scope}[>={Stealth[black]},
    every edge/.style={draw=black, very thick}]
    \path [-] (0) edge (6);
    \path [-] (0) edge (3);
    \path [-] (0) edge (1);
    \path [-] (0) edge (2);
    \path [-] (0) edge (5);
    \path [-] (0) edge (7);
    \path [-] (4) edge (6);
    \path [-] (4) edge (1); 
\path [-] (4) edge (3);
\path [-] (4) edge (1);
\path [-] (4) edge (2);
\path [-] (4) edge (5);
\path [-] (4) edge (7);
    \end{scope}
    \end{tikzpicture}
\end{document}

enter image description here

3
  • Thank you very much for the answer
    – Charlotte
    Oct 9, 2019 at 13:22
  • @Sango FYI, seems like notifications from posts don't work, but I appreciate the mention :) Oct 9, 2019 at 14:12
  • As i have never done Tikz before, without the link i wouldn't have tried. So i give credit where credit is due ;)
    – Sango
    Oct 9, 2019 at 14:26
2

One way is to draw as pure TikZ image, with use of TikZ libraries chains and positioning:

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, 
                positioning}

\begin{document}
    \begin{tikzpicture}[
    node distance = 17mm and 6mm,
      start chain = A going right,
every node/.style = {circle, draw, minimum size=1.1em, 
                     inner sep=2pt, outer sep= 0pt,
                     on chain=A}
                        ]
\node {6};                  % A-1        
\node {3};
\node {1};
\coordinate[on chain];      % A-4
\node {2};
\node {5};
\node {7};                  % A-7
%
\node[above=of A-4]    {0}; % A-8
\node[below=of A-4]    {4}; % A-9
%
\foreach \i in {1,...,7}{\draw (A-8) -- (A-\i) -- (A-9);}
    \end{tikzpicture}
\end{document}

enter image description here

Addendum: another way is use for example forest package, which is based on TikZ package. An elementary solution with using it is:

\documentclass[margin=3mm]{standalone}
\usepackage{forest}

\begin{document}
    \begin{forest}
for tree = {circle, draw, 
            minimum size=1.1em, 
            inner sep=2pt, outer sep= 0pt,
%
            l sep = 12mm,
            s sep= 6mm
            }
[0, name=n0
    [6, name=n1]
    [3, name=n2]
    [1, name=n3]
    [ , coordinate
        [4, name=n7]
    ]
    [2, name=n4]
    [5, name=n5]
    [7, name=n6]
]
%
\foreach \i in {1,...,7}{\draw (n\i) -- (n7);}
    \end{forest}
\end{document}

Result is the same as at the first example.

1
  • Thank you very much for the answer
    – Charlotte
    Oct 9, 2019 at 13:22

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