0

I want to create a simple graph using graphviz which has

  • two nodes (b, c) in the same rank and another single node (a)
  • node b and c each has an unidirectional edge to node a
  • node b and c have an bidirectional edge to each other of which ports are both on the left side ("w")
digraph {
  graph [
    charset = "UTF-8";
    rankdir = LR,
  ];

  b -> a;
  c -> a;
  b:w -> c:w;
  {rank = same; b; c}
}

But I got this graph which the bidirectional edge became unidirectional.
Created graph

I am new to dot language and I don't know why this happened. Can anyone help me? Thanks!

Update
I'm very sorry my first question was so stupid I forgot to include [dir = both]... But actually it was not the real problem.

Actually there were labels with all edges. So the code was

digraph {
  graph [
    charset = "UTF-8";
    rankdir = LR
  ];
  b -> a [label = 1];
  c -> a [label = 2];
  b:w -> c:w [dir = both, label = 3];
  {rank = same; b; c}
}

And this code produces the following graph which the bidirectional edge is changed to unidirectional.
Updated graph
But if I remove all labels from edges ([label = ...]), the edge becomes bidirectional. The edge also becomes bidirectional if I remove both port arguments (:w).

I appreciate if anyone could figure out what is going on here. Thank you again in advance.

yh6
  • 379
  • 2
  • 13
  • This question looks quite a lot of question: https://stackoverflow.com/questions/52188840/how-to-make-an-edge-with-both-direction-in-graphviz and my answer https://stackoverflow.com/a/52188974/1657886 So add attribute `[dir=both]` to the bc edge. – albert Feb 23 '21 at 11:05
  • @albert How stupid am I... Thank you for pointing that out. But actually I found that it was not the exact problem. I appreciate if you could take a look at my update. – yh6 Feb 23 '21 at 13:36
  • 1
    When I add a semi-colon (`;`) after `LR` and add `constraint=false` for the bc edge. it looks all OK to me (versions 2.38 and 2.40). – albert Feb 23 '21 at 14:48
  • @albert It worked, I don't know why it did the trick though. Anyway thank you very much for solving the issue! – yh6 Feb 24 '21 at 04:00

0 Answers0