我有一张Tikz
如下所示的图表:
\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
和subtree3
分别代表高度为 2 和 3 的子树。此图看起来几乎符合我的预期,但从父级到子树的边在边三角形的顶部。
我如何指定边缘应连接到顶部我的三角形?
答案1
我认为你想要的是
edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)}
在选项中tikzpicture
。请参阅“来自父节点的边“在 TiKZ 手册中查看更多有关如何使用此功能的示例。(就目前情况而言,这将使从父节点到子节点的边缘具有非常浅的坡度;您可以通过让子节点进一步远离父节点来纠正这个问题。)