[Tex/LaTex] Draw a special arc from 1 node to another in TikZ

tikz-pgf

Even though I just learned how to draw an arc, I have difficulties in drawing the arcs in the figure. Especially the arc from the second circle to the first one. If I do: \draw[bend left,->] (l2.south) to node [auto] (l1.north) (where l1 is the circle above, and l2 is the circle below), the line will cross the circles and make the picture not pretty.

So does anyone know how to draw the arc from l2 to l1? Another thing is I would like this arc goes from the south of l2, and points to the north-west of l1 (instead of north of l1)

Could anyone help? Thank you very much!

enter image description here

Best Answer

You'll need to define a support point for this. You can use the syntax +(<x>,<y>), which specifies a point relative to the starting point. In order to smooth the curve, you'll have to make sure that the in value of the path segment going into the support point, and the out value of the segment leaving the support point add up to 0. To adjust the path of the curve, you can play with looseness, in looseness and out looseness, which specify how "curvy" the path is.

By specifying an out and in angle for the first and last segment of the path, you can determine at what location the path leaves or enters a node. Alternatively, you could specify (<node name>.north west) to make the path start or end at the top left of a node, or use (<node name>.<angle>) to specify at what angle on the shape outline the path will start or end, with 0 pointing due east, 90 due north, etc.

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning}

\begin{document}

\begin{tikzpicture}[every node/.style={draw,ellipse}]
  \node (A) {A};
  \node [below left=2cm and 0.5cm of A] (B) {B};
\draw[out=-90,in=90,->]  (A) to  (B);
\draw [->] (B)  to [out=-90,in=-90,in looseness=2.5] +(-1cm,1cm) to [out=90,in=135,out looseness=1.5](A);
\end{tikzpicture}

\end{document}

If you're not set on the path leaving node B from the south, but instead make it leave from south west, you can instead just write

\draw [->] (B)  to [out=-135,in=135,in looseness=1.5] (A);