如何使点图形的某些线平行?

时间:2015-12-09 20:46:37

标签: graph graphics graphviz dot directed-graph

当我使用点来绘制下面代码描述的图形时,并非所有中间线都是平行的(即线A - > I和E - > J):

digraph g {rankdir=LR
node [shape = record, height=0.1];
node0[label = "A ", style="filled", color="black", fillcolor="yellow"];
node1[label = "B "];
node2[label = "C "];
node3[label = "D "];
node4[label = "E "];
node5[label = "F "];
node6[label = "G "];
node7[label = "H "];
node8[label = "I "];
node9[label = "J "];
"node5" -> "node0";
"node5" -> "node2";
"node6" -> "node2";
"node6" -> "node4";
"node0" -> "node1";
"node2" -> "node1";
"node2" -> "node3";
"node4" -> "node3";
"node1" -> "node8";
"node1" -> "node7";
"node3" -> "node7";
"node3" -> "node9";
"node0" -> "node8";
"node5" -> "node1";
"node2" -> "node7";
"node6" -> "node3";
"node4" -> "node9";
}

我怎样才能让dot考虑到这一点并使它们并行?

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

如果节点属于同一组,Graphviz会尝试在排名方向上保持边缘直线。

digraph g {rankdir=LR
node [shape = record, height=0.1];
{
  node [group=g1];
  node0[label = "A ", style="filled", color="black", fillcolor="yellow"];
  node8[label = "I "];
}
{
  node [group=g2];
  node4[label = "E "];
  node9[label = "J "];
}
node1[label = "B "];
node2[label = "C "];
node3[label = "D "];
node5[label = "F "];
node6[label = "G "];
node7[label = "H "];
"node5" -> "node0";
"node5" -> "node2";
"node6" -> "node2";
"node6" -> "node4";
"node0" -> "node1";
"node2" -> "node1";
"node2" -> "node3";
"node4" -> "node3";
"node1" -> "node8";
"node1" -> "node7";
"node3" -> "node7";
"node3" -> "node9";
"node0" -> "node8";
"node5" -> "node1";
"node2" -> "node7";
"node6" -> "node3";
"node4" -> "node9";
}