3

Would anyone help me to draw the following two graphs by TikZ? I have difficulties when trying to draw arcs and I did not find good/simple references for that.

enter image description here

enter image description here

This is what I have tried for the first graph:

\begin{tikzpicture}    
  \node[circle,draw] (A) at (-1,0) {};    
  \node[circle,draw] (B) at (5,0) {};    
  \draw  (-5,0) node {}  -- (-1,0) node{} -- (5,0) node{};    
  \draw (A) to[out=20,in=160] (B);    
  \draw (A) to[out=40,in=120] (B);    
  \draw (A) to[out=-20,in=200] (B);    
  \draw (A) to[out=-40,in=220] (B);
\end{tikzpicture}

P/S: Using the below codes of JouleV, I am not sure why I have the unwanted circles around the nodes e0,..., e4 like the following picture:

enter image description here

1
  • Well I can draw straight lines, but for arcs e.g., in the first graph, the arcs e_4, e_2, e_3 I cannot find methods to draw them.
    – Michael Ke
    Commented Feb 18, 2019 at 7:26

2 Answers 2

7

This is a good start for arcs:

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[black] (0,0) circle (1pt) (4,0) circle (1pt) (8,0) circle (1pt);
\draw (0,0)--(4,0) node[midway,above] {$e_0$};
\draw (4,0) to[out=90,in=90] node[midway,above] {$e_4$} (8,0);
\draw (4,0) to[out=30,in=150] node[midway,above] {$e_2$} (8,0);
\draw (4,0) -- node[midway,below] {$e_1$} (8,0);
\draw (4,0) to[out=-60,in=-120] node[midway,below] {$e_3$} (8,0); 
\end{tikzpicture}
\end{document}

enter image description here

If you have defined the node formats before, you have to put the \draw commands to a scope, where you redefine the nodes:

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\fill[black] (0,0) circle (1pt) (4,0) circle (1pt) (8,0) circle (1pt);
\begin{scope}[every node/.style={fill=none,draw=none}]
 \draw (0,0)--(4,0) node[midway,above] {$e_0$};
 \draw (4,0) to[out=90,in=90] node[midway,above] {$e_4$} (8,0);
 \draw (4,0) to[out=30,in=150] node[midway,above] {$e_2$} (8,0);
 \draw (4,0) -- node[midway,below] {$e_1$} (8,0);
 \draw (4,0) to[out=-60,in=-120] node[midway,below] {$e_3$} (8,0); 
\end{scope}
\end{tikzpicture}
\end{document}

Bonus | The second figure:

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{angles,quotes}
\begin{document}
\begin{tikzpicture}
\draw[->] (-1,0)--(5.5,0);
\draw (0,-.5)--(0,4);
\coordinate (o) at (0,0);
\coordinate (a) at (3,0);
\coordinate (c) at (1,3);
\coordinate (b) at (4,2);
\coordinate (bx) at (5,2);
\coordinate (cx) at (2,3);
\coordinate (ax) at (5,0);
\draw[very thick] (o)--(a);
\draw[very thick] (a)--(b) node[midway,above left] {$\varphi'_B$};
\draw[very thick] (b)--(c) node[midway,below] {$\varphi'_A$};
\draw[very thick] (c)--(o) node[midway,right] {$\varphi'_I$};
\draw[dashed] (b)--(bx) (c)--(cx);
\pic[draw,"$\alpha_3$",angle radius=0.3cm,angle eccentricity=2] {angle=ax--a--b};
\pic[draw,"$\alpha_1$",angle radius=0.2cm,angle eccentricity=2] {angle=cx--c--o};
\pic[draw,"$\alpha_2$",angle radius=0.2cm,angle eccentricity=2] {angle=bx--b--c};
\end{tikzpicture}
\end{document}

You need the angles library for angle notations and quotes library to insert the angle names.

8
  • Great, thank you! I used the code but how do I remove the black circles containing e_0, ... , e_4?
    – Michael Ke
    Commented Feb 18, 2019 at 7:53
  • @MichaelKe If you mean the black dots, just comment out the line \fill[black] (0,0) circle (1pt) (4,0) circle (1pt) (8,0) circle (1pt);.
    – user156344
    Commented Feb 18, 2019 at 7:54
  • I used the \documentclass[12pt]{amsart}, so I skipped \documentclass[tikz,border=5mm]{standalone}. Maybe that causes the names of the nodes (like e_0) are inside grey circles, while your outcomes for these codes do not show any circle around the names of the nodes?
    – Michael Ke
    Commented Feb 18, 2019 at 7:58
  • @MichaelKe Yes, it is Ok, standalone is only for MWE purpose. But remember loading tikz! :)
    – user156344
    Commented Feb 18, 2019 at 7:59
  • Thanks, I have posted the pictures that I am not sure why I got those extra circles around the nodes.
    – Michael Ke
    Commented Feb 18, 2019 at 8:06
4

as supplement to the first version of @JouleV answer:

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

    \begin{document}
    \begin{tikzpicture}[
     node distance = 30mm,
     on grid,
dot/.style = {circle, draw, fill, minimum size=3pt, inner sep=0pt,
              node contents={}},
every edge quotes/.style = {inner sep=1pt, font=\footnotesize, auto=left}
                        ]
\node (n1) [dot];
\node (n2) [dot, right=of n1];
\node (n3) [dot, right=of n2];
\path   (n1) edge ["$e_0$"] (n2)
        (n2) edge ["$e_1$"] (n3)
        (n2) edge [bend  left=60,"$e_4$"]   (n3)
        (n2) edge [bend  left,"$e_2$"]      (n3)
        (n2) edge [bend right,"$e_3$"]      (n3)
        ;
    \end{tikzpicture}
    \end{document}

enter image description here

You must log in to answer this question.

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