0

在 DiagrammeR 中,如何创建到节点的边而不是从节点?

对于下面示例中的每个节点,我希望有一个传入边(表示来自模型外部的传入“错误”),最好带有标签。

library(DiagrammeR)

grViz("

    digraph boxes_and_circles {
      graph [nodesep = 2]

      a -> {b c}
      b -> {a c}
      c -> {a b}
    }

")

(出于某种原因,您需要声誉点来发布图片,所以我希望没有它是有意义的)

4

1 回答 1

2


我认为只有通过解决方法才有可能,即放置一些空白节点(如果我理解您的要求):

 library(DiagrammeR)

grViz("

  digraph boxes_and_circles {
   # avoid distortion
  graph [nodesep = 1, layout = circo]

  node [shape = box,
        fontname = Helvetica]
        a;b;c

  #invisible nodes
  node [shape = circle,
        fixedsize = true,
        width = 0.9,
        color = white,
        fontcolor = white]
        da;db;dc

  # define the labels
  edge [color = red, arrowhead = normal]
  da -> a [label = 'a']
  db -> b [label = 'b']
  dc -> c [label = 'c']

  edge [color = black, arrowhead = normal]
  a -> {b c}
  b -> {a c}
  c -> {a b}

  }
  ")

在此处输入图像描述

于 2018-06-13T10:17:09.203 回答