![节点将一个节点放在另一个节点之上](https://linux22.com/image/304481/%E8%8A%82%E7%82%B9%E5%B0%86%E4%B8%80%E4%B8%AA%E8%8A%82%E7%82%B9%E6%94%BE%E5%9C%A8%E5%8F%A6%E4%B8%80%E4%B8%AA%E8%8A%82%E7%82%B9%E4%B9%8B%E4%B8%8A.png)
我是 tikz 的新手,我正在使用以下代码(对 texample.net 进行了轻微修改)绘制 2 棵红黑树。我面临的问题是两棵树都一棵叠在另一棵之上。你能帮我吗?我想做的是将它们放在相同的高度,一棵在左边,一棵在右边
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\tikzset{
treenode/.style = {align=center, inner sep=0pt, text centered,
font=\sffamily},
arn_n/.style = {treenode, circle, white, font=\sffamily\bfseries, draw=black,
fill=black, text width=1.5em},% arbre rouge noir, noeud noir
arn_r/.style = {treenode, circle, red, draw=red,
text width=1.5em, very thick},% arbre rouge noir, noeud rouge
arn_x/.style = {treenode, rectangle, draw=black,
minimum width=0.5em, minimum height=0.5em}% arbre rouge noir, nil
}
\begin{document}
\begin{tikzpicture}[->,>=stealth',level/.style={sibling distance = 5cm/#1,
level distance = 1.5cm}]
\node [arn_r] {15}
child{ node [arn_n] {10}
child{ node [arn_r] {5} edge from parent node[above left]
{$x$}} %for a named pointer
child{ node [arn_x] {}}
}
child{ node [arn_n] {20}
child{ node [arn_r] {18}}
child{ node [arn_x] {}}
}
;
\node [arn_r] {47}
child{ node [arn_n] {38}
child{ node [arn_r] {36}}
child{ node [arn_r] {39}}
}
child{ node [arn_n] {51}
child{ node [arn_r] {49}}
child{ node [arn_x] {}}
}
;
\end{tikzpicture}
\end{document}