2021-01-08
参考资料
Graphviz 画图的一些总结
python模块graphviz使用入门
Graphviz入门
python代码
from graphviz import Digraph
g = Digraph(name="最大流_1--5", format='png')
g.attr(rankdir='LR')
g.node(name='1',color='green')
g.node(name='2',color='blue')
g.node(name='3',color='blue')
g.node(name='4',color='blue')
g.node(name='5',color='green')
g.node(name='6',color='blue')
g.node(name='7',color='blue')
g.node(name='8',color='blue')
g.edge('1','7',color='red',label = "3/3",labelfontcolor = 'red')
g.edge('1','2',color='black',label = "6/20",labelfontcolor = 'red')
g.edge('1','3',color='black',label = "4/20",labelfontcolor = 'red')
g.edge('2','6',color='red',label = "1/1",labelfontcolor = 'red')
g.edge('2','4',color='black',label = "5/20",labelfontcolor = 'red')
g.edge('3','5',color='red',label = "4/4",labelfontcolor = 'red')
g.edge('4','8',color='red',label = "5/5",labelfontcolor = 'red')
g.edge('6','5',color='black',label = "1/20",labelfontcolor = 'red')
g.edge('7','5',color='black',label = "8/20",labelfontcolor = 'red')
g.edge('8','7',color='black',label = "5/20",labelfontcolor = 'red')
g.view()
|