当前位置: 首页>>代码示例>>Python>>正文


Python PortGraph.nb_connections方法代码示例

本文整理汇总了Python中openalea.workflow.port_graph.PortGraph.nb_connections方法的典型用法代码示例。如果您正苦于以下问题:Python PortGraph.nb_connections方法的具体用法?Python PortGraph.nb_connections怎么用?Python PortGraph.nb_connections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openalea.workflow.port_graph.PortGraph的用法示例。


在下文中一共展示了PortGraph.nb_connections方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: portgraph_nb_connections

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import nb_connections [as 别名]
def portgraph_nb_connections():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()
    vid3 = pg.add_vertex()

    assert_raises(InvalidPort, lambda: pg.nb_connections(0))

    pid1 = pg.add_in_port(vid1, 0)
    pid2 = pg.add_in_port(vid1, 1)
    pid3 = pg.add_out_port(vid2, 0)
    pid4 = pg.add_out_port(vid3, 0)

    for pid in (pid1, pid2, pid3, pid4):
        assert pg.nb_connections(pid) == 0

    pg.connect(pid3, pid1)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid1) == 1
    assert pg.nb_connections(pid2) == 0
    assert pg.nb_connections(pid4) == 0

    pg.connect(pid4, pid1)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid4) == 1
    assert pg.nb_connections(pid1) == 2
    assert pg.nb_connections(pid2) == 0

    pg.connect(pid4, pid2)
    assert pg.nb_connections(pid3) == 1
    assert pg.nb_connections(pid4) == 2
    assert pg.nb_connections(pid1) == 2
    assert pg.nb_connections(pid2) == 1
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:35,代码来源:test_port_graph.py

示例2: test_portgraph_remove_port

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import nb_connections [as 别名]
def test_portgraph_remove_port():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()

    pid1 = pg.add_in_port(vid1, "in")
    pid2 = pg.add_out_port(vid2, "out")

    pg.connect(pid2, pid1)

    # raise error if global port id dos not exist
    assert_raises(InvalidPort, lambda: pg.remove_port(pid1 + pid2 + 1))

    pg.remove_port(pid1)
    assert len(tuple(pg.ports(vid1))) == 0
    assert tuple(pg.ports(vid2)) == (pid2,)
    assert pg.nb_connections(pid2) == 0
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:19,代码来源:test_port_graph.py

示例3: test_portgraph_remove_vertex

# 需要导入模块: from openalea.workflow.port_graph import PortGraph [as 别名]
# 或者: from openalea.workflow.port_graph.PortGraph import nb_connections [as 别名]
def test_portgraph_remove_vertex():
    pg = PortGraph()
    vid1 = pg.add_vertex()
    vid2 = pg.add_vertex()

    pid1 = pg.add_in_port(vid1, "in")
    pid2 = pg.add_out_port(vid2, "out")

    pg.connect(pid2, pid1)

    assert_raises(InvalidVertex, lambda: pg.remove_vertex(vid1 + vid2 + 1))

    pg.remove_vertex(vid1)
    assert tuple(pg.ports()) == (pid2,)
    assert_raises(InvalidVertex, lambda: pg.ports(vid1).next())
    assert tuple(pg.ports(vid2)) == (pid2,)
    assert pg.nb_connections(pid2) == 0
    assert pg.nb_neighbors(vid2) == 0
开发者ID:revesansparole,项目名称:oaworkflow,代码行数:20,代码来源:test_port_graph.py


注:本文中的openalea.workflow.port_graph.PortGraph.nb_connections方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。