这可能与How to place edge labels ON edge in graphviz有关:我有以下图表,我使用命令dot -Teps g.dot > g.eps
可视化:
graph triple {
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
{
User -- Triple [label = "1"];
Object -- Triple [label = "1"];
}
{
rank=same;
User;
Object;
}
Triple -- Tag [label="n"];
}
我希望通过在图表的左侧放置User和Triple之间的标签来使结果更加对称。
答案 0 :(得分:25)
使用graphviz无法手动放置边缘标签。
但是,您可以使用headlabel
,labeldistance
和labelangle
属性:
graph triple {
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
{
User -- Triple [headlabel = "1", labeldistance=2.5, labelangle=20];
Object -- Triple [headlabel = "1", labeldistance=2.5, labelangle=-20];
}
{
rank=same;
User;
Object;
}
Triple -- Tag [label="n"];
}
输出:
答案 1 :(得分:6)
以下是使用splines=false
和双边的第二种解决方法:
graph {
splines=false;
node [shape=box]; User; Object; Tag;
node [shape=diamond,style=filled]; Triple;
{
User -- Triple [label = "1"];
User -- Triple [label = ""];
Object -- Triple [label = ""];
Object -- Triple [label = "1"];
}
{
rank=same;
User;
Object;
}
Triple -- Tag [label="n"];
}
输出: