如何在graphviz网络图中添加3个点?

问题描述

我有一个简单的 graphviz 网络图,我想在其中展示我的模型的神经网络架构:

DiagrammeR::grViz("digraph G {

rankdir = LR

{a b z} -> {x1,x2,x100} -> Y
                  
}")

输出到:

enter image description here

现在,我想在第一层中的 b 之后和第二层中的 x2 之后添加 3 个点(垂直),表明这些层中的节点比我可以显示的多一个演讲。例如,第二层(x1x2 ... x100)中有100个节点(单元)。

我想要的是类似于本例中的 3 个点(取自 this study/source):

enter image description here

解决方法

有两个挑战

  1. 找到一种显示垂直省略号(三个点)的方法
  2. 保持原始节点按所需顺序和位置显示

如果输出是 SVG 而不是 png,则以下在我的计算机上工作。如果 SVG 对你没问题,那就去吧。如果您需要直接创建一个 png,嵌入的图像就可以了。

digraph G {
rankdir = LR
splines=false  // straight lines,not curves
// define ellipsis nodes
E1[shape=none  label="⋮" fontsize=30]
E2[shape=none  label="⋮" fontsize=30]
{rank=same a b E1 z}       // align on same rank
{rank=same x1 x2 E2 x100}  // align on same rank

{a b z} -> {x1,x2,x100} -> Y

// invisible edges to order nodes
edge[style=invis]
a->b->E1->z 
x1->x2->E2->x100 
}

给予(svg 由 Imagemagick 转换为 png):
enter image description here