0

In DiagrammeR, how can I create an edge to a node but not from a node?

For each of the nodes in the below example, I'd like to have an incoming edge (representing the incoming 'error' from outside of the model), preferably with a label.

library(DiagrammeR)

grViz("

    digraph boxes_and_circles {
      graph [nodesep = 2]

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

")

(for some reason you need reputation points to post images, so I hope it makes sense without)

s__
  • 9,270
  • 3
  • 27
  • 45
Alexander
  • 72
  • 7

1 Answers1

2


I think it is possible only with a workaround, i.e. put some blank nodes (If I've understood your request):

 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

s__
  • 9,270
  • 3
  • 27
  • 45
  • Yes, thank you, this is exactly what I want, but than without distorting the positions of the three nodes (those form a triangle with equal distances to one another in the first example), and with short straight inbound edges (the ones you colored red). If it can't be done without hidden nodes it will probably be a bit of a pain in the ass.. – Alexander Jun 13 '18 at 12:17