Goal
I'm trying to connect the nodes of my graph using a horizontal-vertical-horizontal line.
MWE
Consider the following example:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs, calc}
\begin{document}
\begin{tikzpicture}
\graph[left anchor=east, right anchor=west] {
a -- { b, c }
};
\end{tikzpicture}
\end{document}
What argument do I need to pass to \graph to customize my edges, and how, to go from this:
to this (not to scale):
My ideas
I tried specifying the key /tikz/graphs/new --, but I'm not sure how to do this. My main idea was to add the following to the previous code:
...
\graph[..., new --={\draw[#3] (#1) -| ($(#1)!.5!(#2)$) |- (#2) #4;}] {
...
and variants of that, trying to specify my function in various ways:
\graph[..., new --/.code={...}] { % or /.code 4 args or /.style
---------------------------------------------------------------------------
\graph[..., every new --={...}] { % or /.code or /.code 4 args or /.style or nothing
---------------------------------------------------------------------------
\tikzset{ % This seemed to be a good lead too
manhattan/.code 4 args={\draw[#3] (#1) -| ($(#1)!.5!(#2)$) |- (#2) #4;},
}
...
\graph[..., new --=manhattan] { % or /tikz/manhattan
\pgfkeys{/user/manhattan/.code 4 args={...}} % Same use as above
I also tested these ideas specifying the /tikz/graphs/default edge kind key instead of /tikz/graphs/new --.
Here are the two recurring error messages I encountered during my quest:
// Trying to define a key with /.code 4 args
! Illegal parameter number in definition of \pgfkeys@temp.
<to be read again>
3
l.7 ...[#3] (#1) -| ($(#1)!.5!(#2)$) |- (#2) #4;}]
{
// Directly in \graph
! Argument of \tikz@parse@calculator has an extra }.
<inserted text>
\par
l.11 ...#3] (#1) -| ($(#1)!.5!(#2)$) |- (#2) #4;}]
{
?
Anyway, I'm lost, so thanks for any help here !



new --/.code n args={4}{…}and then#1ist the start node,#2is the target,#3is the edge's options and#4are the nodes. Though, I'd suggest just setting the rightto path(for example in/tikz/every new --) or just for alledges. – Qrrbrbirlbel Jun 19 '23 at 20:45new --/.style={/user/manhattan=#1}might work, too , if you want to use that custom style. But.code 4 argsis not a correct handler. Pgfkeys only knows.code(one argument),.code 2 args(2),.code n args={<n>}{…}wherenis less or equal 9 orcode args={???}{…}where you can give any argument specification (just like\def.) – Qrrbrbirlbel Jun 19 '23 at 20:50