问题描述
我写了一个python类来显示和设置二进制搜索树的动画.但是,由pyDot edge和node命令生成的图形似乎不允许我控制连接树的每个元素的箭头的角度或方向.
I wrote a python class to display and animate binary search trees. Yet the graphs produced by the pyDot edge and node commands don't seem to allow me to control the angle or direction of the arrows connecting each element of my tree.
有许多控制节点形状的控件,但似乎没有任何关于线角度的控件.我希望找到某种最小角度参数,以便在将其添加到图形时将其添加到我的边缘?
There are lots of controls for shape of the nodes but there does not seem to be any control for angle of the lines. I was hoping to find some kind of minimum angle parameter to add to my edges as they are added to the graph?
这是我的代码示例,其中我使用edge命令绘制节点:
This is a sample of my code where I draw nodes using the edge command:
def draw(parent_name, child_name):
# color for lines = red
edge = pydot.Edge(parent_name, child_name, color="#ff0000")
graph.add_edge(edge)
最终结果是,当几个节点只有一个孩子时,我的二叉搜索树图看起来不像传统的树结构.
The end result is that my graphs for binary search trees don't look like the traditional tree structures when several nodes have only one child.
这里是指向我的项目的链接,您可以在其中看到其他有效的结果: http://www.embeddedcomponents.com/blogs/2013/12/visualizing-software-tree-structures/
Here is a link to my project where you can see the otherwise working results:http://www.embeddedcomponents.com/blogs/2013/12/visualizing-software-tree-structures/
推荐答案
:
不可能使用点直接直接控制边缘天使语言,但添加不可见的边缘可以为您提供所需的结果,请参见示例,它会生成以下图形:
it is not possible to directly control edges angels using the dot language, but adding invisible edges can give you the result you want, see an example here that generates the following graph:
这篇关于使用pyDot生成图形时是否可以控制线角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!