15

I have problem with an small graph. The path between the node J and B should to the right of node I.

Is there a way to do this?

\documentclass[11pt]{article} 
\pagestyle{empty}  
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata}

\begin{document}
\centering
\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,initial/.style    ={}]
    \node[state]        (0)                     {};
    \node[state]        (A) [below =of 0]       {};
    \node[state]        (B) [below =of A]       {B};
    \node[state]        (C) [below left =of B]      {};
    \node[state]        (D) [below left =of C]      {};
    \node[state]        (E) [below right =of C]     {};
    \node[state]        (F) [below left =of D]      {};
    \node[state]        (G) [below right =of D]     {};
    \node[state]        (H) [below right =of E]     {};
    \node[state]        (I) [right =of H]       {I};
    \node[state]        (J) [yshift=-2cm,below right =of G]     {J};
    \node[state]        (X) [yshift=-1cm,below =of J]       {};

    \tikzset{mystyle/.style={->}} 
    \path   (0) edge    [mystyle]   node    {}  (A);
    \path   (A) edge    [mystyle]   node    {}  (B);
    \path   (B) edge    [mystyle]   node    {}  (C);
    \path   (C) edge    [mystyle]   node    {}  (D);
    \path   (C) edge    [mystyle]   node    {}  (E);
    \path   (D) edge    [mystyle]   node    {}  (F);
    \path   (D) edge    [mystyle]   node    {}  (G);
    \path   (E) edge    [mystyle]   node    {}  (H);
    \path   (B) edge    [mystyle]   node    {}  (I);
    \path   (F) edge    [mystyle]   node    {}  (J);
    \path   (G) edge    [mystyle]   node    {}  (J);
    \path   (H) edge    [mystyle]   node    {}  (J);
    \path   (I) edge    [mystyle]   node    {}  (J);
    \path   (J) edge    [mystyle]   node    {}  (X);

    \tikzset{mystyle/.style={->,relative=false,in=0,out=0}}
    \draw [->] (J) to [bend right=100 ] (B);
    %\path  (J) edge    [mystyle]   node    {}  (B); %similar problem
\end{tikzpicture}

\end{document}
  • 3
    Add a min distance option: \draw [->] (J) to [bend right=100,min distance=5cm] (B); – Sašo Živanović Aug 28 '12 at 22:09
  • 2
    @SašoŽivanović You should turn your comment into an answer... – Paul Gaborit Aug 29 '12 at 7:13
12

just tell him to move to the right by adding an intermediate point

j'ai rajouté la librairie : calc

et modifié le chemin: \draw [->] (J) to [out=0,in=-90] ($(I)+(1,0)$) to [out=90, in=0 ] (B);

\documentclass[11pt]{article} 
\pagestyle{empty}  
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,calc}

\begin{document}
\centering
\begin{tikzpicture}[>=stealth',shorten >=1pt,node distance=2cm,on grid,initial/.style    ={}]
    \node[state]        (0)                     {};
    \node[state]        (A) [below =of 0]       {};
    \node[state]        (B) [below =of A]       {B};
    \node[state]        (C) [below left =of B]      {};
    \node[state]        (D) [below left =of C]      {};
    \node[state]        (E) [below right =of C]     {};
    \node[state]        (F) [below left =of D]      {};
    \node[state]        (G) [below right =of D]     {};
    \node[state]        (H) [below right =of E]     {};
    \node[state]        (I) [right =of H]       {I};
    \node[state]        (J) [yshift=-2cm,below right =of G]     {J};
    \node[state]        (X) [yshift=-1cm,below =of J]       {};

    \tikzset{mystyle/.style={->}} 
    \path   (0) edge    [mystyle]   node    {}  (A);
    \path   (A) edge    [mystyle]   node    {}  (B);
    \path   (B) edge    [mystyle]   node    {}  (C);
    \path   (C) edge    [mystyle]   node    {}  (D);
    \path   (C) edge    [mystyle]   node    {}  (E);
    \path   (D) edge    [mystyle]   node    {}  (F);
    \path   (D) edge    [mystyle]   node    {}  (G);
    \path   (E) edge    [mystyle]   node    {}  (H);
    \path   (B) edge    [mystyle]   node    {}  (I);
    \path   (F) edge    [mystyle]   node    {}  (J);
    \path   (G) edge    [mystyle]   node    {}  (J);
    \path   (H) edge    [mystyle]   node    {}  (J);
    \path   (I) edge    [mystyle]   node    {}  (J);
    \path   (J) edge    [mystyle]   node    {}  (X);

    \tikzset{mystyle/.style={->,relative=false,in=0,out=0}}
    \draw [->] (J) to [out=0,in=-90] ($(I)+(1,0)$) to [out=90, in=0 ] (B);
    %\path  (J) edge    [mystyle]   node    {}  (B); %similar problem
\end{tikzpicture}

\end{document}

enter image description here

38

You can play with the looseness=<value> key: the bigger the number, the wider the curve gets. This example illustrates it, just replace the draw by this:

Replacement:

\foreach \x [evaluate=\x as \c using \x*30] in {0.2,0.4,...,3}
{\draw[->,red!\c!blue] (J) to[out=30-20*\x,in=20*\x-30,looseness=\x] (B);}

Effect:

with increasing looseness (from 0.2 to 3) the color fades from blue to red.

enter image description here

  • 4
    Great style choice for the colors. – percusse Aug 29 '12 at 9:13

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.