我最近开始使用DOT语言来描述二叉树的结构。以下示例允许在每个节点内绘制一个二进制树作为标签。
graph tree {
0 [shape=ellipse]
1 [shape=ellipse]
2 [shape=ellipse]
3 [shape=ellipse]
4 [shape=ellipse]
0 -- 1
0 -- 2
2 -- 3
2 -- 4
}
现在,我想在每个节点附近打印一些附加信息,但不在包含节点标签的椭圆内打印。换句话说,如何在节点附近打印描述字符串?我应该如何修改上面的代码才能实现这个目标?
答案 0 :(得分:2)
此脚本,添加了行
graph tree {
0 [shape=ellipse]
1 [shape=ellipse]
2 [shape=ellipse]
3 [shape=ellipse]
4 [shape=ellipse]
0 -- 1
0 -- 2
2 -- 3
2 -- 4
node [shape=none]
edge [style="invis"]
rank="same"
subgraph { 0 -- "desc of 0" }
subgraph { 1 -- "desc of 1" }
subgraph { 2 -- "desc of 2" }
subgraph { 3 -- "desc of 3" }
subgraph { 4 -- "desc of 4" }
}
为您的描述生成合理的图像