【问题标题】:How to get connected neighbour nodes on the same height when drawing in GraphViz?在 GraphViz 中绘图时如何在相同高度上获得连接的邻居节点?
【发布时间】:2014-08-26 14:24:57
【问题描述】:

我正在尝试使用GraphViz 绘制以下(后缀树):

digraph G {
  1[label = " "];
  2[label = " "];
  3[label = " "];
  4[label = " "];
  5[label = " "];
  6[label = " "];
  7[label = " "];
  8[label = " "];

  // edges drawn vertically, all fine.
  1 -> 2 [label="ab"];
  1 -> 3 [label=" b"];
  1 -> 4 [label=" c$"];
  2 -> 5 [label="abc$"];
  2 -> 6 [label="c$"];
  3 -> 7 [label=" abc$"];
  3 -> 8 [label="c$"];

  // node 3 should be on the right side of node 2, and
  // a cross line should be drawn horizontally

  2 -> 3 [style=dotted,label="abc$"];

}

问题是,跟随边“abc$”和“b”到达的节点与跟随“ab”和“c$”到达的那两个节点不在同一高度。

有没有人遇到过同样的情况,可以分享一下解决方案吗?

【问题讨论】:

    标签: graph graphviz suffix-tree


    【解决方案1】:

    啊,好吧,没有搜索合适的术语! "placing nodes on a horizontal line",提供解决方案。

    此代码现在将节点 2、3、4 正确定位在同一“水平线”上。

    digraph G {
      1[label = " "];
      2[label = " "];
      3[label = " "];
      4[label = " "];
      5[label = " "];
      6[label = " "];
      7[label = " "];
      8[label = " "];
    
      node[group=sameheight];
        { rank = same; 2; 3; 4; }
    
      1 -> 2 [label="ab"];
      1 -> 3 [label=" b"];
      1 -> 4 [label=" c$"];
      2 -> 3 [style=dotted];
      2 -> 5 [label="abc$"];
      2 -> 6 [label="c$"];
      3 -> 7 [label=" abc$"];
      3 -> 8 [label="c$"];
    }
    

    希望对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-17
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-27
      • 2017-10-08
      相关资源
      最近更新 更多