【问题标题】:How to change Graphviz subgraph rank?如何更改 Graphviz 子图排名?
【发布时间】:2017-06-07 14:35:10
【问题描述】:

我希望子图 clusterCG 具有与 3 相同的等级(clusterCG 不应包含 3)

digraph G{
 rankdir = LR;
 node [shape = none]

 1->2->3->4[arrowhead=none]

 node [shape = ellipse]

 A->A2->A3;

 subgraph clusterCG{
  shape = rect;
  rank=same;
  A2;
  B;
  C;
  color=blue;
  label="C";
 }

 { rank=same; 1; A;}
 { rank=same; 3; CG;}
 { rank=same; 4; A3;}
}

CG 生成为具有等级 3 的独立节点。

我希望子图 clusterCG 的排名为 3。

【问题讨论】:

  • FDSg,您不应该接受答案吗?对我来说看起来不错!我知道你自己写的,但它很有帮助。
  • 我同意。这帮助我找出了我在不同类型的布局中遇到的一个难题。谢谢。

标签: graphviz dot


【解决方案1】:

通过“newrank=true”使用不同的排名算法

 digraph G {
 newrank=true
 rankdir = LR;
 node [shape = none]

 1->2->3->4[arrowhead=none]

 node [shape = ellipse]

 A->A2->A3;

 subgraph clusterCG{
  shape = rect;
  rank=same;

  A2;
  B;
  C;
  color=blue;
  label="C";
 }

 { rank=same; 1; A;}
 { rank=same; 3; A2}
 { rank=same; 4; A3;}
}

【讨论】:

    【解决方案2】:

    也许不是最好的解决方案,但似乎零大小的节点是唯一有效的方法

    digraph G{
     rankdir = LR;
     node [shape = none]
    
    1->2->3->4[arrowhead=none]
    
    node [shape = ellipse]
    ACG[shape = none,label="",width=0, height=0];
    
    CG->A2 [style=invis,constraint=false];
    
    A->ACG[arrowhead=none];
    ACG->A2->A3;
    
     subgraph clusterCG{
      shape = rect;
      rank=same;
      A2;
      B;
      C;
      color=blue;
      label="C";
     }
    
     { rank=same; 1; A;}
     { rank=same; 2; ACG;}
     { rank=same; 4; A3;}
    
    }
    

    【讨论】:

      猜你喜欢
      • 2011-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 2012-11-01
      • 2014-02-25
      • 1970-01-01
      • 2012-06-08
      • 2011-05-29
      相关资源
      最近更新 更多