代码之家  ›  专栏  ›  技术社区  ›  Davy Landman

如何在graphviz中强制同一列中的所有节点?

  •  19
  • Davy Landman  · 技术社区  · 15 年前

    我试图用graphviz对某个流进行建模,但我不知道如何对下图进行建模以共享同一水平中心

    digraph exmp {
       A -> B -> C -> D
       C -> E [constraint=false]
       A -> C [style="dotted", constraint=false]
       A -> D [style="dotted",  constraint=false]
       B -> D [constraint=false]
       D -> A [style="dashed", constraint=false]
       C -> A [style="dashed", constraint=false]
    
    
       subgraph cluster_hackToSinkIt { E -> F }
       { rank="sink" E F }
    }
    

    结果如下图所示:

    rendered image

    我的问题是,如何将e->f定位在d下,使其位于同一列中?

    1 回复  |  直到 10 年前
        1
  •  27
  •   Zeta    10 年前

    至少 as of May 2007 ,不能强制“列” 本身 但你 可以 应用 重量 有助于强制对齐的边缘。但实际上,在这种情况下,如果你只添加一条从d到e的不可见边,你就得到了垂直对齐。

    digraph exmp {
        A -> B -> C -> D
        C -> E [constraint=false]
        A -> C [style="dotted", constraint=false]
        A -> D [style="dotted",  constraint=false]
        B -> D [constraint=false]
        D -> A [style="dashed", constraint=false]
        C -> A [style="dashed", constraint=false]
        D -> E [style="invis"] // <---- important new line
    
    
        subgraph cluster_hackToSinkIt { E -> F }
        { rank="sink" E F }
    }
    

    fixed dot image

    我不知道有什么方法可以把边缘强制到一边或另一边。