如何在节点graphviz中设置头尾位置

时间:2018-12-20 04:29:38

标签: graphviz

我无法控制2个节点之间的边缘的头尾位置。

我正在像下面的图形一样设置一个节点

questionGraph

digraph G{
  node [shape = "box"]
  a -> b
  b -> a
}

2 个答案:

答案 0 :(得分:0)

可以使用The dot language中指定的罗盘点或使用headporttailport属性来定义边缘的头尾位置:

digraph G{
  node [shape = "box"]
  a:w -> b:w
  b -> a [headport=e, tailport=e]
}

答案 1 :(得分:0)

第一部分基本上与@marapet已经给出的答案相同:

digraph G
{
   node[ shape = "box" ];
   a:w -> b:w;
   a:e -> b:e[ dir = back ];
}

它产生一个带有圆形边缘的图形:

enter image description here

如果可以,那么就应该接受marapet的回答。

如果您坚持帖子中提供的形状,则需要执行一些更复杂的过程:

digraph G
{
    // we create the two nodes to be displayed
    node[ shape = "box" ];
    a b;
    //we also create four empty nodes for routing the edges
    node[ shape = point, height = 0 ];
    x1 x2 x3 x4;
    // we make sure that the nodes are arranged on the right levels
    { rank = same; x1 a x2 }
    { rank = same; x3 b x4 }

    // we draw the edges one by one as the heads are varying
    x1 -> a[ dir = none ];
    a -> x2[ dir = back ];
    x1 -> x3[ dir = none ];
    x2 -> x4[ dir = none ];
    b -> x4[ dir = none ];
    x3 -> b;
}

这给你

enter image description here