0

I would like to draw the graph in the picture below using LaTeX (tikz). I was trying but I do not know how to make it.

enter image description hereshape

2

Based on @chsk answer (+1), with some effort to make code a bit more concise:

\documentclass[border=3.141592]{article}
\usepackage{tikz}

\begin{document}
    \begin{tikzpicture}[
dot/.style = {circle, fill, inner sep=1pt},
bend angle = 60    
                        ]
    \begin{scope}[nodes=dot]
\node (x1) [label=135:$x_1$] at (210:4) {};
\node (x2) [label=135:$x_2$] at (210:2) {};
\node (x3) [label=180:$x_3$]            {};
%
\node (x4) [label=225:$x_4$] at (330:2)  {};
\node (x5) [label=225:$x_5$] at (330:4)  {};
%
\node (x6) [label=  0:$x_6$] at (90:2)  {};
\node (x7) [label=  0:$x_7$] at (90:4)  {};
    \end{scope}        
\draw   (x1) -- (x3) -- (x5)
        (x3) -- (x7)
        (x2) -- (x4) -- (x6) -- (x2)
        %
        (x3) to [bend left] (x1) 
        (x3) to [bend left] (x5) 
        (x3) to [bend left] (x7);
    \end{tikzpicture}
\end{document}

enter image description here

2

Here's a fairly quick-and-dirty attempt:

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture}
        \node[draw, circle, fill=black, inner sep=1pt] (x1) at (210:4) {};
        \node[draw, circle, fill=black, inner sep=1pt] (x2) at (210:2) {};
        \node[draw, circle, fill=black, inner sep=1pt] (x3) at (0,0)   {};
        \node[draw, circle, fill=black, inner sep=1pt] (x4) at (330:2) {};
        \node[draw, circle, fill=black, inner sep=1pt] (x5) at (330:4) {};
        \node[draw, circle, fill=black, inner sep=1pt] (x6) at (90:2)  {};
        \node[draw, circle, fill=black, inner sep=1pt] (x7) at (90:4)  {};
        \draw (x3) -- (x1);
        \draw (x3) -- (x5);
        \draw (x3) -- (x7);
        \draw (x2) -- (x4) -- (x6) -- (x2);
        \draw (x3) edge[out=150, in=210] (x7);
        \draw (x3) edge[out= 30, in= 90] (x5);
        \draw (x3) edge[out=270, in=330] (x1);
        \node[anchor=north east]          at (x1) {$x_1$};
        \node[anchor=south east]          at (x2) {$x_2$};
        \node[anchor=east, xshift=-0.1cm] at (x3) {$x_3$};
        \node[anchor=north east]          at (x4) {$x_4$};
        \node[anchor=north west]          at (x5) {$x_5$};
        \node[anchor=south east]          at (x6) {$x_6$};
        \node[anchor=south]               at (x7) {$x_7$};
    \end{tikzpicture}
\end{document}

enter image description here

This places a a number of nodes at named coordinates (x1 to x7) and draws them as circles filled with black. inner sep=1pt is used to shrink these circles; their size is determined by their label text, which is empty here, and inner sep controls how much extra space there is around the label, so you need to set that to something small to get a smaller circle.

Nodes are placed using the <angle>:<distance> syntax for the most part, so x2 for instance, is two cm from the origin, at an angle of 210 degrees. (This is quite a useful TikZ feature, well worth remembering.)

Edges are drawn as usual; the curved ones specify the angles at which the edges leave the source nodes (out=...) and enter the target nodes (in=...). Usually it would preferable to use (x2) -- (x4) -- (x6) -- cycle instead of explicitly repeating the first coordinate, BTW, but for some reason this isn't working here; don't ask me why.

Labels are placed as nodes at the previously set coordinates; anchor= controls which point of the new node will be placed at the specified coordinate. The node labelling x3 is also shifted a bit to keep it from clashing with the previously-drawn lines.

I hope that this'll help --- not just with your immediate problem, but also with learning a bit of TikZ!

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.