【发布时间】:2020-06-02 07:10:10
【问题描述】:
我试图获得从右侧退出节点并从左侧进入的直线边缘。
我尝试使用splines='line,但它似乎没有创建直线。下面的代码,在 jupyter notebook 中执行。
from graphviz import Digraph
g = Digraph('G', filename='cluster.gv')
with g.subgraph(name='cluster_0') as c:
c.attr(style='filled', color='lightgrey')
c.node_attr.update(style='filled', color='white')
c.edges([('a0', 'a1'), ('a1', 'a2'), ('a2', 'a3')])
c.attr(label='process #1')
with g.subgraph(name='cluster_1') as c:
c.attr(color='blue')
c.node_attr['style'] = 'filled'
c.edges([('b0', 'b1'), ('b1', 'b2'), ('b2', 'b3')])
c.attr(label='process #2')
g.edge('a1', 'b3',splines='line',tailport="e", headport="w", constraint='false')
g.edge('a2', 'b0',splines='line',tailport="e", headport="w", constraint='false')
g.view()
这是代码生成的图表: Graph
【问题讨论】: