【问题标题】:Place Graphviz nodes side by side without arrow将 Graphviz 节点并排放置,不带箭头
【发布时间】:2020-03-08 02:31:26
【问题描述】:

有没有什么方法可以在 Graphviz 上自动实现与 (油漆制作)相同的结果?蓝色节点纯粹是为了提供信息,每个节点都必须有一个在他身边。

【问题讨论】:

标签: graph graphviz dot


【解决方案1】:

将 xlabel 与 html 表格或不可见边缘一起使用

digraph G {

A[xlabel=<<table border="1" cellborder="0" color="blue"><tr><td>a</td></tr></table>>]
A->B->D
A->C->D
{
    node[shape=rect color=blue]
A1 B1 C1 D1
}
{
    edge[dir=none style=dotted]
    //edge[dir=none color=invis]
{rank=same A->A1}
{rank=same B->B1}
{rank=same C->C1}
{rank=same D->D1}
}
}

【讨论】:

  • 感谢您的回答。是否可以避免 xlabel 和边缘重叠?
  • 不,你不能控制 xlabel 的位置,它只是应该在附近
【解决方案2】:

通过混合使用 nodesepma​​rginsubgraphclusters,您可以非常接近:

digraph pairs { nodesep=.02
  splines=line 
  subgraph cluster_1 { margin="24"  peripheries=0 
   { edge [style=invis] rank=same
    n1 [ label="a"    shape=oval height=.6  ]
    n1_X [   shape=rect color=blue height=.4 ]
    n1 -> n1_X  [style=invis]
   }
  }

  subgraph cluster_2 { margin="24"  peripheries=0 
   { edge [style=invis] rank=same
    n2 [ label="{2}"    shape=oval height=.6  ]
    n2_X [   shape=rect color=blue height=.4 ]
    n2 -> n2_X  [style=invis]
   }
  }

// more of the same ...

  edge[dir=none]
n1 -> {n2 n3 n4 n5 }
n2 -> {n6 n7 }
n3 -> {n6 n8 n9 }
n4 -> {n7 n10 n13 }
n5 -> {n8 n10 }
n6 -> {n11 n15 }
n7 -> {n15 }
n8 -> {n11 n12 }
n9 -> {n12 n13 }
n10 -> {n14 }
n11 -> {n17 }
n12 -> {n16 }
n13 -> {n15 n16 }
n14 -> {n16 }
n15 -> {n17 }
n16 -> {n17 }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-22
    • 2016-02-06
    相关资源
    最近更新 更多