Moving Graphviz edge out of the way

Deadly 提交于 2020-01-04 05:26:27

问题


In this graph:

Rendered using Graphviz/Dot, the red edge connects two nodes, whereas the other edges connect ports inside the nodes. The nodes have HTML labels, and the TDs for the inputs and outputs have a PORT attribute.

Is there a way to make Dot move the red node "out of the way", that is to the left or to the right, possibly curved, so that it does not go over the black edges.

It is for an automatically generated graph that can contain more than two nodes, not necessarily all vertically aligned.

The source code of this graph:

digraph G {
rankdir=TB
src [shape=plaintext label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BORDER="0"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD WIDTH="20"></TD><TD PORT="in1" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in1</FONT></TD><TD WIDTH="10"></TD><TD PORT="in2" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in2</FONT></TD><TD WIDTH="10"></TD><TD PORT="in3" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in3</FONT></TD><TD WIDTH="20"></TD></TR></TABLE></TD></TR><TR><TD BORDER="1" STYLE="ROUNDED" CELLPADDING="4" COLOR="black">A<BR/><FONT POINT-SIZE="10">node</FONT></TD></TR><TR><TD BORDER="0"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD WIDTH="20"></TD><TD PORT="out1" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">out1</FONT></TD><TD WIDTH="10"></TD><TD PORT="out2" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">out2</FONT></TD><TD WIDTH="20"></TD></TR></TABLE></TD></TR></TABLE>>];


rankdir=TB
snk [shape=plaintext label=<<TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD BORDER="0"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD WIDTH="20"></TD><TD PORT="in1" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in1</FONT></TD><TD WIDTH="10"></TD><TD PORT="in2" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in2</FONT></TD><TD WIDTH="10"></TD><TD PORT="in3" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">in3</FONT></TD><TD WIDTH="20"></TD></TR></TABLE></TD></TR><TR><TD BORDER="1" STYLE="ROUNDED" CELLPADDING="4" COLOR="black">B<BR/><FONT POINT-SIZE="10">node</FONT></TD></TR><TR><TD BORDER="0"><TABLE BORDER="0" CELLBORDER="0" CELLSPACING="0" CELLPADDING="0"><TR><TD WIDTH="20"></TD><TD PORT="out1" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">out1</FONT></TD><TD WIDTH="10"></TD><TD PORT="out2" BORDER="1" CELLPADDING="1"><FONT POINT-SIZE="10">out2</FONT></TD><TD WIDTH="20"></TD></TR></TABLE></TD></TR></TABLE>>];

    snk -> src [style="", arrowhead="vee", color=red, headlabel=<>, fontsize=10, labelangle=45, labeldistance=2.0, labelfontcolor=black];

    src:out1 -> snk:in1 [style="", arrowhead="normal", color=black, headlabel=<>, fontsize=10, labelangle=45, labeldistance=2.0, labelfontcolor=black];
    src:out1 -> snk:in2 [style="", arrowhead="normal", color=black, headlabel=<>, fontsize=10, labelangle=45, labeldistance=2.0, labelfontcolor=black];
    src:out2 -> snk:in3 [style="", arrowhead="normal", color=black, headlabel=<>, fontsize=10, labelangle=45, labeldistance=2.0, labelfontcolor=black];

    {rank=source; src}
    {rank=sink; snk}

}

回答1:


You could add compass points to your edge definition:

snk:se -> src:ne

or

snk:e -> src:e

for an arrow to the right, or

snk:sw -> src:nw

or

snk:w -> src:w

for an arrow on the left side.

Of course, I'm not sure whether this would work when there are several nodes which are not aligned.



来源:https://stackoverflow.com/questions/42157650/moving-graphviz-edge-out-of-the-way

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!