# In Tikz, how can I specify where an edge connects to a child node?

I have a Tikz graph that looks something like this:

\usepackage{tikz}
\usetikzlibrary{shapes,positioning,shadows,arrows}

...

\begin{tikzpicture}[
singleNode/.style={rectangle, draw=none, rounded corners=1mm, fill=green, drop shadow,
text centered, anchor=north},
subtree2/.style={regular polygon, regular polygon sides=3, draw=none, fill=blue,
drop shadow, text centered, anchor=north, minimum height=6em},
subtree3/.style={regular polygon, regular polygon sides=3, draw=none, fill=blue,
drop shadow, text centered, anchor=north, minimum height=9em},
level distance=1em, growth parent anchor=south
]
\node (k3) [singleNode] {$k_3$} [sibling distance=20em]
child{ [sibling distance=14em]
node (k1) [singleNode] {$k_1$}
child{
node (A) [subtree3] {$A$}
}
child{ [sibling distance=8em]
node (k2) [singleNode] {$k_2$}
child{
node (B) [subtree3, fill=red] {$B$}
}
child{
node (C) [subtree2] {$C$}
}
}
}
child{
node (D) [subtree3] {$D$}
}
;
\end{tikzpicture}


subtree2 and subtree3 represent subtrees of height 2 and 3, respectively. This graph looks almost as I intend it, but the edge from a parent to a subtree connects at the side of the triangle, rather than the top.

How can I specify that the edge should connect to the top of my triangles?

-

## 1 Answer

I think what you want is something like

edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)}


in the options to the tikzpicture. See the section on "Edges From the Parent Node" in the TiKZ manual to see some more examples of what you can do with this. (As it stands, this will give the edges from the parents to the children a very shallow slope; you can rectify this perhaps by having the children descend further from the parents.)

-