1

I have been trying to complete the graph in the picture with an edge drawn with points. (a)........(b). I have searched the internet but found nothing, can I get your help? Here is the code I am using.

\begin{figure}[H]
\centering
    \begin{tikzpicture}
    \node[ellipse,draw] (2) at (1,0.4) {$1$};
    \node[ellipse,draw] (1) at (-1.5,0.4) {$2$};
    \node[ellipse,draw] (7) at (-1.5,3.6){$3$};    
    \node[ellipse,draw] (8) at (-2.1,2){$4$};
    \node[ellipse,draw] (9) at (2,3){$5$};
        
    \node[ellipse,draw] (3) at (-6,0.5) {$6$};
    \node[ellipse,draw] (4) at (-6.3,4) {$7$};
    \node[ellipse,draw] (6) at (-8,1) {$8$};
    \node[ellipse,draw] (10) at (-8.5,3.9){$9$};
    \draw (1) -- (2);
    \draw (7) -- (8);
    \draw (8) -- (9);
    \draw (8) -- (1);
    \draw (9) -- (7);
    \draw (2) -- (8);
    \draw (2) -- (7);
    \draw (2) -- (9);
    \draw (1) -- (9);   
    \draw (1) -- (7);
    
    \draw (10) -- (6);
    \draw (10) -- (4);
    \draw (4) -- (3);
    \draw (6)--(4);
    \draw (3)--(10);
    \draw (6)--(3);
    
    \end{tikzpicture}
\caption{Illustration}
\end{figure}

Desired output:

enter image description here

I am sorry for the bad drawing. I know how to do a curved edge. Example of the drawing: \draw (7) to [out=20,in=160,looseness=0.5] (10);

I would just like to know how to change it to a point line, as I have not found that type of arrow in the documentation (only for a the a part of the edges, not all of them). Thanks in advance :).

1
  • Welcome to TeX.SE!!! Just write \draw[dotted] (7) to [out=130,in=40] (10); or \draw[densely dotted] (7) to [out=130,in=40] (10); Commented Aug 17, 2021 at 18:09

2 Answers 2

1

You just add a option such as [dashed], [dotted], etc.

See the PGF TiKz manual under the section Graphic Parameters: Line Width, Line Cap, and Line Join, currently on page 174. The manual is your best friend, I would recommend to do the tutorials in there as they are a really good start for a beginner.

Also I renamed your nodes to be more logical.

enter image description here

\documentclass[margin=2cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\begin{tikzpicture}
    \node[ellipse,draw] (1) at (1,0.4) {$1$};
    \node[ellipse,draw] (2) at (-1.5,0.4) {$2$};
    \node[ellipse,draw] (3) at (-1.5,3.6){$3$};    
    \node[ellipse,draw] (4) at (-2.1,2){$4$};
    \node[ellipse,draw] (5) at (2,3){$5$};
        
    \node[ellipse,draw] (6) at (-6,0.5) {$6$};
    \node[ellipse,draw] (7) at (-6.3,4) {$7$};
    \node[ellipse,draw] (8) at (-8,1) {$8$};
    \node[ellipse,draw] (9) at (-8.5,3.9){$9$};

    \draw (1)
        edge (2)
        edge (3)
        edge (4)
        edge (5);
    \draw (2)
        edge (3)
        edge (4)
        edge (5);
    \draw (3)
        edge (4)
        edge (5);
    \draw (4) -- (5);

    \draw (6)
        edge (7)
        edge (8)
        edge (9);
    \draw (7)
        edge (8)
        edge (9);
    \draw (8) -- (9);

    \draw[dashed] (9) to[out=30,in=140,looseness=1] (3);
\end{tikzpicture}
\end{document}
1
  • Thanks for the answer an the manual, I'll surely look into it.
    – Rommy087
    Commented Aug 17, 2021 at 18:37
1

As I said in my comment, you only need to add the option densely dotted (for example) to your proposed last \draw command:

\draw[densely dotted] (7) to [out=20,in=160,looseness=0.5] (10);

I propose this example, in which I have renamed the nodes for legibility, and drawn the edges with the help of \foreach commands to reduce the code.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{shapes.geometric} % ellipse nodes

\begin{document}
\begin{tikzpicture}
% pentagon nodes
\node[ellipse,draw] (1) at ( 1  ,0.4) {$1$};
\node[ellipse,draw] (2) at (-1.5,0.4) {$2$};
\node[ellipse,draw] (3) at (-1.5,3.6) {$3$};    
\node[ellipse,draw] (4) at (-2.1,2)   {$4$};
\node[ellipse,draw] (5) at ( 2  ,3)   {$5$};
% quadrilateral nodes
\node[ellipse,draw] (6) at (-6  ,0.5) {$6$};
\node[ellipse,draw] (7) at (-6.3,4)   {$7$};
\node[ellipse,draw] (8) at (-8  ,1)   {$8$};
\node[ellipse,draw] (9) at (-8.5,3.9) {$9$};
% pentagon graph
\foreach\i[evaluate=\i as \ii using {int(\i+1)}] in {1,...,4} \foreach\j in {\ii,...,5}
  \draw (\i) -- (\j);
% quadrilateral graph
\foreach\i[evaluate=\i as \ii using {int(\i+1)}] in {6,7,8}   \foreach\j in {\ii,...,9}
  \draw (\i) -- (\j);
% link between the two graphs
\draw[red,thick,densely dotted] (3) to [out=130,in=40] (9);
\end{tikzpicture}
\end{document}

enter image description here

1
  • Thanks, the \foreach addition is so nice.
    – Rommy087
    Commented Aug 18, 2021 at 19:24

You must log in to answer this question.

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