4
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
    \begin{figure}
        \centering
        \begin{tikzpicture}
        \node[shape=circle,draw=black] (s) at (-3,3) {$1$};  
        \node[shape=circle,draw=black] (sr) at (3,3)  {$2$}; 
        \node[shape=circle,draw=black] (r) at  (-5,0) {$3$};  
        \node[shape=circle,draw=black] (r2) at  (0,0) {$4$};  
        \node[shape=circle,draw=black] (sr2) at  (3,-3) {$5$};  
        \node[shape=circle,draw=black] (sr3) at  (-3,-3) {$6$};  
        
        
        
        \draw (s) -- (sr); 
        \draw (s) -- (r2); 
        \draw (sr) -- (sr2); 
        \draw (sr2) -- (sr3); 
        \draw (sr3) -- (s); 
        \draw (r2) -- (sr); 
        \draw (s) -- (r); 
        \draw (r) -- (sr3); 
        \draw (sr) -- (r); 
        \draw (sr2) -- (r); 
        \draw (s) -- (r2); 
        \draw (r2) -- (sr3); 
        \draw (sr) -- (r2); 
        \draw (sr2) -- (r2); 
        \end{tikzpicture}
        
        
    \end{figure}
    
\end{document}

I am getting the following figure as output. https://imgur.com/pHLbRQN But I want to make the figure appear like this: tur

How to draw the edges like this? Please help someone.

4

Make the following edit in your code--

enter image description here

\draw (sr) to [bend right=90,looseness=1.5] (r); 
\draw (sr2) to [bend right=-90,looseness=1.5](r); 
1
  • Thanks a lot , it helped a lot +1! – Math_Freak Jul 12 '20 at 14:39
1

I can think of two possible solutions:

Solution 1

You could replace the -- with to which accepts extra options like an angle at which the path should leave from its origin and also at which the path should arrive at its destination.

In your case, you would replace

\draw (sr) -- (r); 
\draw (sr2) -- (r);

with

\draw (sr) to [in = 90, out = 135] (r);
\draw (sr2) to [in = -90, out = -135] (r);

Play around with the angles to better understand how they work. To make this simple solution look good in your case, you would also have to move the node r further left.

Solution 2

The solution above could be extended with an intermediate helper coordinate on the way from r to sr/sr2. The following code uses a coordinate with the x-value of r and a y-value halfway between r and sr/sr2.

\draw (sr) to [out = 135, in = 90] ($(sr-|r)!0.5!(r)$) -- (r);
\draw (sr2) to [out = -135, in = -90] ($(sr2-|r)!0.5!(r)$) -- (r);

This way the position of r could remain the same. For this code to work the calc library is required, which can be included with \usetikzlibrary{calc}.

To visualize how the syntax of ($(sr-|r)!0.5!(r)$) works you could draw small circles at the different parts of it

\fill [blue] (sr-|r) circle (1mm); % mixing x-coordinate of r with y-coordinate of sr
\fill [red] ($(sr-|r)!0.5!(r)$) circle (1mm); % going to the center (0.5) between the previous coordinate and r

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.