我该如何正确乳胶显示我的AVL树?独奏左子挂直降
题
在下面的代码几乎完美地工作,9,7然而孩子,而不是垂直向下悬挂的作为左子。我怎样才能解决这个?
\usepackage{tikz}
\usepackage{xytree}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
\node [circle,draw] {4}
child {
node [circle,draw] {2}
child {node [circle,draw] {1}
}
child {
node [circle,draw]{3}
}
}
child {node [circle,draw] {6}
child {node [circle,draw] {5}
}
child {node [circle,draw] {9}
child {node [circle, draw] {7}}
}
};
\end{tikzpicture}}
谢谢,CB
解决方案 2
与所建议的tikz手册协商后,我能够纠正此如下:
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
\node [circle,draw] {4}
child {
node [circle,draw] {2}
child {node [circle,draw] {1}
}
child {
node [circle,draw]{3}
}
}
child {node [circle,draw] {6}
child {node [circle,draw] {5}
}
child {node [circle,draw] {9}
child {node [circle, draw] {7}}
child [missing]
}
};
\end{tikzpicture}
其他提示
下面的代码为我工作。它基于你的代码,与所述变化
1)使用tikz库树和 2)单个节点的格式的变化(节点7)
有关的更多信息请参见tikz手册
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[level/.style={sibling distance=60mm/#1}]
\node [circle,draw] {4}
child {
node [circle,draw] {2}
child {node [circle,draw] {1}
}
child {
node [circle,draw]{3}
}
}
child {node [circle,draw] {6}
child {node [circle,draw] {5}
}
child {node [circle,draw] {9}
child[grow via three points={one child at (-1,-1) and two children at (-.5,1) and (.5,1)}] {node [circle, draw] {7}}
}
};
\end{tikzpicture}
\end{document}
不隶属于 StackOverflow