python - 如何在pydot中使用带箭头的线条

标签 python pydot

我使用 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/

相关文章:

python - Pydot 不能很好地处理换行符?

python - 在 Anaconda 环境中安装 pydot 和 graphviz 包

python - 为什么 pip 不安装包的当前版本?

python - 即使安装后也无法导入 pydot

python - theano 打印 pydotprint - 运行时错误 : failed to import pydot

java - Python 的 map 函数是否有 Java 等价物?

python - 在 ubuntu 20.04LTS 上安装 pygame 的问题

python tarfile错误: struct.错误:解包需要长度为4的字符串参数

python - 两组虚拟变量的频率/列联表

python - 我收到错误 No JSON object could be decoded but with a valid JSON file