如何在 LaTex 中正确显示我的 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
The below code almost works perfectly, however the child of 9, 7, hangs straight down instead of as a left-child. How can I correct this?
\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}}
Thanks, CB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面的代码对我有用。它基于您的代码,并进行了更改
1) 使用 tikz 库树和
2) 更改单个节点的格式(节点7)
更多信息请参阅 tikz 手册
The code below works for me. It is based on your code, with the changes
1) use the tikz library trees and
2) change of the formatting of a single node (node 7)
For more information see the tikz manual
按照建议查阅 tikz 手册后,我能够按如下方式更正此问题。
After consulting with the tikz manual as suggested, I was able to correct this as follows.