我使用 pydot 和这些命令绘制了一个二叉搜索树
graph = pydot.Dot(graph_type='graph')
visit(n5, BFS)
graph.write_png('example1_graph.png')
函数 View 遍历树并调用一个简单的例程来绘制边缘:
def draw(parent_name, child_name):
# color for lines = red
edge = pydot.Edge(parent_name, child_name, color="#ff0000")
graph.add_edge(edge)
但是连接节点的线是简单的直线。有没有办法把简单的线条变成有向的箭头?
最佳答案
要使用箭头连接节点,请使用有向图类型。更改第一行代码,连接节点的线将是箭头而不是直线。
graph = pydot.Dot(graph_type='digraph')
关于python - 如何在pydot中使用带箭头的线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20458948/