本文整理汇总了Python中openalea.workflow.port_graph.PortGraph.vertex方法的典型用法代码示例。如果您正苦于以下问题:Python PortGraph.vertex方法的具体用法?Python PortGraph.vertex怎么用?Python PortGraph.vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openalea.workflow.port_graph.PortGraph
的用法示例。
在下文中一共展示了PortGraph.vertex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_portgraph_vertex
# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import vertex [as 别名]
def test_portgraph_vertex():
pg = PortGraph()
assert_raises(InvalidPort, lambda: pg.vertex(0))
vid = pg.add_vertex()
pid1 = pg.add_in_port(vid, 0)
pid2 = pg.add_out_port(vid, 0)
assert pg.vertex(pid1) == vid
assert pg.vertex(pid2) == vid
示例2: test_portgraph_big
# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import vertex [as 别名]
def test_portgraph_big():
pg = PortGraph()
vid1 = pg.add_vertex()
pid11 = pg.add_out_port(vid1, "out")
vid2 = pg.add_vertex()
pid21 = pg.add_out_port(vid2, "out")
vid3 = pg.add_vertex()
pid31 = pg.add_in_port(vid3, "in1")
pid32 = pg.add_in_port(vid3, "in2")
pid33 = pg.add_out_port(vid3, "res")
vid4 = pg.add_vertex()
pid41 = pg.add_in_port(vid4, "in")
eid1 = pg.connect(pid11, pid31)
eid2 = pg.connect(pid21, pid32)
pg.connect(pid33, pid41)
assert pg.source_port(eid1) == pid11
assert pg.target_port(eid2) == pid32
assert set(pg.out_ports(vid1)) == {pid11}
assert set(pg.in_ports(vid3)) == {pid31, pid32}
assert set(pg.ports(vid3)) == {pid31, pid32, pid33}
assert pg.is_in_port(pid31)
assert pg.is_out_port(pid11)
assert pg.vertex(pid11) == vid1
assert set(pg.connected_ports(pid11)) == {pid31}
assert set(pg.connected_edges(pid21)) == {eid2}
assert pg.out_port(vid1, "out") == pid11
assert pg.in_port(vid3, "in1") == pid31
assert_raises(InvalidPort, lambda: pg.connect(pid11, pid33))
pg.remove_port(pid33)
assert set(pg.connected_ports(pid41)) == set()
assert set(pg.out_edges(vid3)) == set()
assert_raises(InvalidPort, lambda: pg.is_in_port(pid33))