# TikZ graphs: Specify edge target anchor

I have the following code:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\tikz \graph[grow right sep=20,nodes={draw,rectangle}] { a -> {b, long node name} };
\end{document}


Which produces this output:

I'd like to have the edge "a" -> "long node name" to not go from east to north but from south to west. Is this possible while still using just one \graph call? Or do I need to specify that edge manually in an extra command?

(That is, I have basically the same problem as in the question Edge anchor in tikz, but I want to use TikZ' graph drawing capabilities instead of manually creating edges.)

To obtain west anchor for node long node name you can use right anchor=west.

Code

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\begin{document}
\tikz \graph[grow right sep=20,nodes={draw,rectangle},right anchor=west] { a -> {b, long node name} };
\end{document}


Result

• The arrows should go from south to west, though. :) – Alenanno Feb 7 '16 at 11:04

This is what you want, I think.

I never used \graph. The natural way I do something like what you asked is using \nodes and anchors, as follows:

\documentclass[tikz]{standalone}
\usetikzlibrary{graphs}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node[draw] (a) {a};
\node[draw,anchor=west] (b) at ($(a)+(1cm,0)$) {b};
\node[draw,anchor=west] (c) at ($(a)+(1cm,-1cm)$) {long node name};
\draw[->] (a) -- (b);
\draw[->] (a.south) -- (c.west);
\end{tikzpicture}
\end{document}


Sure, you have to set a proper distance between the nodes; if not so, the arrow head could intersect the rectangle, but there's no way to avoid this but changing arrow heads. Furthermore, you could use curved arrows.