TransWikia.com

Draw curve does not cross a node

TeX - LaTeX Asked by Diego Rangel on May 31, 2021

I am in need of help to make the following graph:

enter image description here

But I can’t bend the edge without going over the vertex.

 begin{tikzpicture}[scale = 0.75]
            tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
            tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
            
            node[roundnode = black] (1) at (30, 2.01){1};
            node[roundnode = black] (2) at (31.91, 0.62){2};
            node[roundnode = black] (3) at (31.18, -1.63){3};
            node[roundnode = black] (4) at (28.82, -1.63){4};
            node[roundnode = black] (5) at (28.09, 0.62){5};
            
            draw
            (1) edge[-,thick]   (2)
            (2) edge[-,thick]   (3)
            (3) edge[-,thick]   (4)
            (4) edge[-,thick]   (5)
            (5) edge[-,thick]   (1)
            %(3) edge[-,thick]   (4)
           
        end{tikzpicture}

3 Answers

Another option is to use controls:

the graph

documentclass[tikz, border=20]{standalone}
usetikzlibrary{calc}
begin{document}
   begin{tikzpicture}[scale = 0.75]
        tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
        tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
        
        node[roundnode = black] (1) at (30, 2.01){1};
        node[roundnode = black] (2) at (31.91, 0.62){2};
        node[roundnode = black] (3) at (31.18, -1.63){3};
        node[roundnode = black] (4) at (28.82, -1.63){4};
        node[roundnode = black] (5) at (28.09, 0.62){5};
            
        draw
        (1) edge[-,thick]   (2)
        (2) edge[-,thick]   (3)
        (3) edge[-,thick]   (4)
        (4) edge[-,thick]   (5)
        (5) edge[-,thick]   (1)
        (3) edge[-,thick]   (4);
            
        draw (1) edge[-,thick] (4);
        draw (1) edge[-,thick] (3);
        draw[thick] (5) .. controls ($(1) + (0, 1.5)$) .. (2);
        draw[thick] (4) .. controls ($(3) + (0.8, -1)$) .. (2);
    
    end{tikzpicture}
end{document}

Correct answer by Willoughby on May 31, 2021

You only need enough bend.

documentclass[tikz,border=2mm]{standalone}
begin{document}
begin{tikzpicture}
 draw[enough bend/.style={looseness=2,bend left=80}] foreach x [evaluate=x as y using {162-72*x}] in {1,...,5}
  {(y:2) node[circle,fill,inner sep=1.5pt,label=y:{$x$}](x){}
  ifnumx>1
   edge (1) edge (thenumexprx-1)
  fi}
  (5) to[enough bend] (2)
  (2) to[enough bend] (4);
end{tikzpicture}
end{document}

enter image description here

Answered by user237902 on May 31, 2021

edge bend

Use either [out=90,in=90] to specify out angle and in angle or [bend right=<val>], then looseness to allow your path to be more or less away from your nodes.

documentclass[tikz,border=3.14mm]{standalone}

begin{document}

    begin{tikzpicture}[thick,scale = 0.75]
            tikzstyle{every state}=[fill opacity=0.5,text opacity=1,semithick,minimum size=10pt]
            tikzset{roundnode/.style={thick, draw = black, fill = white, outer sep = 1.5, circle, minimum size = 10pt, scale = 0.75}}
            
            foreach i in {1,...,5}
                node[roundnode] (i) at (162-72*i:3){i};
            
            draw
            (1) edge   (2)
            (2) edge   (3)
            (3) edge   (4)
            (4) edge   (5)
            (5) edge   (1)
            (3) edge   (1)
            (4) edge   (1)
            (4) to[bend right=80,looseness=2] (2)
            (5) edge[out=90,in=90,looseness=2]   (2);
           
    end{tikzpicture}

end{document}

Answered by SebGlav on May 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP