本文整理汇总了Python中openalea.workflow.port_graph.PortGraph.add_edge方法的典型用法代码示例。如果您正苦于以下问题:Python PortGraph.add_edge方法的具体用法?Python PortGraph.add_edge怎么用?Python PortGraph.add_edge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.workflow.port_graph.PortGraph
的用法示例。
在下文中一共展示了PortGraph.add_edge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_portgraph_edge_connected_to_ports
# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import add_edge [as 别名]
def test_portgraph_edge_connected_to_ports():
pg = PortGraph()
vid1 = pg.add_vertex()
vid2 = pg.add_vertex()
# method add_edge is forbidden
assert_raises(UserWarning, lambda: pg.add_edge((vid1, vid2)))
# connect to None port raises InvalidPort
assert_raises(InvalidPort, lambda: pg.connect(None, None))
pid1 = pg.add_out_port(vid1, "out")
pid2 = pg.add_in_port(vid2, "in")
assert_raises(InvalidPort, lambda: pg.connect(pid1, None))
assert_raises(InvalidPort, lambda: pg.connect(None, pid2))
# connect from in port to out port raises InvalidPort
assert_raises(InvalidPort, lambda: pg.connect(pid2, pid1))
# test connect is working
eid = pg.connect(pid1, pid2)
assert pg.source_port(eid) == pid1
assert pg.target_port(eid) == pid2