本文整理匯總了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