本文整理汇总了Python中pydot.Dot.set_edge_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python Dot.set_edge_defaults方法的具体用法?Python Dot.set_edge_defaults怎么用?Python Dot.set_edge_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydot.Dot
的用法示例。
在下文中一共展示了Dot.set_edge_defaults方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_example_graph
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_edge_defaults [as 别名]
def create_example_graph():
g = Dot(graph_name="workflow: example",
labelloc="t", label="workflow: example", fontsize=18, fontcolor="blue")
g.set_node_defaults(shape="box", fontsize=12)
g.set_edge_defaults(fontsize=13, labeldistance=3)
n1 = Node(name="Start")
g.add_node(n1)
n2 = Node(name="StepTrueEnd", color="#04B45F")
g.add_node(n2)
n3 = Node(name="StepFalse")
g.add_node(n3)
n4 = Node(name="StepFalse2")
g.add_node(n4)
n5 = Node(name="StepFalse3End", color="#04B45F")
g.add_node(n5)
e1 = true_edge(n1, n2)
g.add_edge(e1)
e2 = false_edge(n1, n3)
g.add_edge(e2)
e3 = true_edge(n3, n4)
g.add_edge(e3)
e_back = false_edge(n4, n1, label="back if false")
g.add_edge(e_back)
e4 = true_edge(n4, n5)
g.add_edge(e4)
return g
示例2: create_graph_from_workflow
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import set_edge_defaults [as 别名]
def create_graph_from_workflow(self, workflow):
"""
:type workflow: Workflow
:rtype: Dot
"""
known_nodes = {}
start = workflow.getStartNode()
name = workflow.getName()
g = Dot(graph_name=name, ranksep=1,
labelloc="t", label="workflow: " + name, fontsize=18, fontcolor="blue")
g.set_node_defaults(shape="box", fontsize=12)
g.set_edge_defaults(fontsize=13, labeldistance=3)
def add_node_rek(node):
"""Recurses through the workflow graph and adds nodes and edges.
Repeated nodes are ignored (cycle detection).
:type node: core.tree.Node
"""
name = node.getName()
if name in known_nodes:
return known_nodes[name]
dot_node = Node(name=name)
g.add_node(dot_node)
known_nodes[name] = dot_node
logg.debug("created node %s", name)
try:
true_next_id = node.getTrueId()
except:
true_next_id = None
if true_next_id:
true_next = workflow.getStep(true_next_id)
true_dot_next = add_node_rek(true_next)
true_label = node.getTrueLabel() or " "
g.add_edge(true_edge(dot_node, true_dot_next, label=true_label))
logg.debug("created True edge: %s -> %s", name, true_next_id)
try:
false_next_id = node.getFalseId()
except:
false_next_id = None
if false_next_id:
false_next = workflow.getStep(false_next_id)
false_dot_next = add_node_rek(false_next)
false_label = node.getFalseLabel() or " "
g.add_edge(false_edge(dot_node, false_dot_next, label=false_label))
logg.debug("created False edge: %s -> %s", name, false_next_id)
if not (true_next_id or false_next_id):
# end node with no connections
dot_node.set("color", "#04B45F")
return dot_node
# traverse from start node
add_node_rek(start)
return g