首页 > 解决方案 > 如何显示相同的节点标题

问题描述

我想像在 Wiki 1中一样绘制 RB-Tree ,1

但我找不到为不同节点显示相同标题的可能性(在本例中为 nil - 节点)。有可能的?

  digraph "rb-tree"{
  bgcolor = whitesmoke;
  forcelabels = true;
  margin = 0;
  node [shape = circle,
        style = filled,
        fontsize = 14,
        margin = 0,
        fillcolor = black,
        fontcolor = white];
  edge [fontsize = 10,
        arrowhead = vee];
8 [fillcolor = red];
17 [fillcolor = red];
nil_8l [shape = box];
nil_8r [shape = box];
nil_17l [shape = box];
nil_17r [shape = box];
13->8;
13->17;
8->nil_8l;
8->nil_8r;
17->nil_17l;
17->nil_17r;
}

标签: graphviz

解决方案


Graphiz 可以设置标签。所以使用:

 digraph "rb-tree"{
  bgcolor = whitesmoke;
  forcelabels = true;
  margin = 0;
  node [shape = circle,
        style = filled,
        fontsize = 14,
        margin = 0,
        fillcolor = black,
        fontcolor = white];
  edge [fontsize = 10,
        arrowhead = vee];
8 [fillcolor = red];
17 [fillcolor = red];
nil_8l [shape = box label="nil"];
nil_8r [shape = box label="nil"];
nil_17l [shape = box label="nil"];
nil_17r [shape = box label="nil"];
13->8;
13->17;
8->nil_8l;
8->nil_8r;
17->nil_17l;
17->nil_17r;
}

推荐阅读