下面的代码几乎可以完美运行,但是 9, 7 的 child 直接垂下而不是作为左 child 。我该如何纠正?
\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
最佳答案
下面的代码对我有用。它基于您的代码,并进行了更改
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}
关于latex - 如何在 LaTex 中正确显示我的 AVL 树?独生左子直垂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2454526/