【问题标题】:In DiagrammeR, how to create an edge to a node, but not from a node?在 DiagrammeR 中,如何创建到节点的边,而不是从节点?
【发布时间】:2018-06-13 20:22:33
【问题描述】:

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

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

library(DiagrammeR)

grViz("

    digraph boxes_and_circles {
      graph [nodesep = 2]

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

")

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

【问题讨论】:

    标签: r diagrammer


    【解决方案1】:


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

     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}
    
      }
      ")
    

    【讨论】:

    • 是的,谢谢,这正是我想要的,但不会扭曲三个节点的位置(在第一个示例中,它们形成一个彼此距离相等的三角形),并且短直的入站边缘(你涂成红色的那些)。如果没有隐藏节点就无法完成,那可能会有点麻烦..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    相关资源
    最近更新 更多