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

时间:2018-06-13 08:12:57

标签: r diagrammer

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

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

library(DiagrammeR)

grViz("

    digraph boxes_and_circles {
      graph [nodesep = 2]

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

")

(出于某种原因,你需要声望点来张贴图片,所以我希望没有这个意义)

1 个答案:

答案 0 :(得分:0)


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

 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}

  }
  ")

enter image description here

相关问题