A few notes before hand:
- The
arrows (and the arrows.spaced) library is deprecated since version 3.0 of TikZ/PGF. It still works, but the new arrows.meta library offers so much more options and reliability.
- The
? of=? syntax is deprecated (and really shouldn't be used anymore), see also Difference between "right of=" and "right=of" in PGF/TikZ. Use the positioning library and the below=? of ? syntax. The behavior of the old keys can be generated with the on grid options.
- I have used the
chains library (which relieves us from using repeatable using \node and below=of. Some may say that even chains is "outdated" and the new graphs library is much more powerful (some would be correct). I added an example for the graphs library. Adding the edge paths inside the \graph options and/or as part of the graphs library is left to the reader.
Indeed, it seems my udlr family seems to help here.
You will need the files
in your texmf tree or somewhere else where LaTeX can find them (in the same folder as your main .tex file for instance).
Amongst others it allows you to use the r-rl path operator which means to draw an orthogonal connection between to coordinates in which you start from the first and go to the right then up- or downwards and then left to the target coordinate (or node).
You can write r-rl[distance=?] to change the distance between nodes/coordinates and the vertical part of the path (default: 0.5cm). The option from center adds the distance from the center of nodes (instead of their borders).
In your example I add an additional (auxiliary) name for the last node and add with the coordinate (@) a coordinate on the connection which allows me to use the same \path specification repeatedly. This @ coordinate (with an default pos=.5) is placed at middle of the vertical part of the r-rl connection.
All these options and how they effect the placement of nodes/coordinates along the path are explained in my answer to Vertical and horizontal lines in pgf-tikz.
If you still want to use |-, I'd advise you to use a to path as defined in:
rl/.style={
near start,
to path={(\tikztostart) -- ++(#1,0) |- (\tikztotarget) \tikztonodes}},
rl/.default=.5
and then you can easily do
\foreach \i in {4,...,1}
\path (@.east) edge[line, rl] coordinate (@) (ch-\i);
Note that you have to .east otherwise the first connection is much closer to the 4 and 5 nodes as the distance in ++(X, Y) is calculates from the center of nodes. (A coordinate is only a point so the .east anchor is just the same as the coordinate without an anchor.)
The rl style also sets near start (which is a short-cut for pos=.25) so that it automatically uses a point halfway on the vertical part.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{paths.ortho, chains, graphs}
\begin{document}
\begin{tikzpicture}[
shorten >= 1pt, node distance=.4cm, semithick,
line/.style = {draw=black, thick},
team/.style = {circle, draw=blue!50, fill=blue!20, minimum size=8mm},
]
\begin{scope}[start chain=ch going below]
\foreach \i in {1,...,5} \node [on chain, team] {\small \i};
\end{scope}
\path (ch-end) [late options={alias=@}];
\foreach \i in {4,...,1}
\path[line] (@) r-rl coordinate (@) (ch-\i);
\end{tikzpicture}
\begin{tikzpicture}[
shorten >= 1pt, semithick,
line/.style = {draw=black, thick},
team/.style = {circle, draw=blue!50, fill=blue!20, minimum size=8mm}
]
\graph[name=C, branch down sep=.4cm, typeset=\small\tikzgraphnodetext, nodes=team]
{\foreach \i in {1,...,5}{\i}};
\path (C 5) [late options={alias=@}];
\foreach \i in {4,...,1}
\path[line] (@) r-rl coordinate (@) (C \i);
\end{tikzpicture}
\end{document}
Output

udlrlibrary of our @Qrrbrbirlbel that can be found in http://tex.stackexchange.com/questions/102385/how-to-draw-a-return-arrow-from-node-3-to-node-1 But I didn't use it and he warns about the incompatibility possibilities.In the meantime you can use the
– percusse Apr 12 '15 at 11:05calccomputation.(node) ++(1cm,0cm)as it calculates the difference to the.centerofnode(which might just be inside the node itself), it also makes the first connection closer to the nodes as the other connections are to the previous connection. – Qrrbrbirlbel Apr 12 '15 at 19:18