控制graphviz(dot2tex)中节点的布局?
我是 graphviz 新手,只是想知道如何确定图中的相对节点位置。例如,如果我想绘制一个简单的三角形“abc”,节点“a”位于顶部,节点“b”和“c”位于底部同一水平,我应该如何告诉 graphviz 布局根据需要节点?
我尝试了以下操作:
graph G
{
node [shape="circle"];
edge [lblstyle="auto"];
{rank=min; "a"}
a -- b [label = "-"];
a -- c [label = "-"];
{rank=same; "b" "c"}
b -- c [label = "+"];
}
但输出将节点“a”和“b”定位在顶部同一级别,节点“c”位于底部。
此外,是否可以在同一个图中并排绘制两个这样的三角形(之间有适当的空间)?如果有,是如何实施的?
多谢。
I am new to graphviz and am just wondering how to determine the relative node positioning in a graph. For example, if I want to draw a simple triangle 'abc', with node 'a' being at the top and nodes 'b' and 'c' on the same level at the bottom, how should I tell graphviz to lay out the nodes as desired?
I tried the following:
graph G
{
node [shape="circle"];
edge [lblstyle="auto"];
{rank=min; "a"}
a -- b [label = "-"];
a -- c [label = "-"];
{rank=same; "b" "c"}
b -- c [label = "+"];
}
but the output positions nodes 'a' and 'b' on the same level at the top, with node 'c' at the bottom.
In addition, is it possible to draw two such triangles side-by-side (with a nice appropriate space in between) in the same graph? if so, how is it implemented?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我得到了 a 在顶部,位于 b 和 c 上方的中心(见图)。
您的标记稍微简化了(什么是 lblstyle ?),在用点渲染时似乎达到了您想要的效果:
您使用什么版本的 graphviz?
并且并排有两个三角形:
但是,如果事情变得更加复杂,则可能很难让 graphviz 完全按照人们想要的方式布局所有内容。这实际上是 graphviz 的优势 - 应用布局算法以避免用户干预。
I actually get a on top, centered above b and c (see image).
Your markup, slightly simplified (what's lblstyle ?), seems to achieve what you want when rendered with dot:
What version of graphviz do you use?
And to have two triangles side by side:
However, if things get more complex, it may be difficult to have graphviz layout everything exactly as one would like. That's actually the strength of graphviz - applying layout algorithms in order to not have a user intervene.