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


Python PointUndirectedGraph.init_2d_grid方法代码示例

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


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

示例1: test_init_2d_grid

# 需要导入模块: from menpo.shape import PointUndirectedGraph [as 别名]
# 或者: from menpo.shape.PointUndirectedGraph import init_2d_grid [as 别名]
def test_init_2d_grid():
    g = PointTree.init_2d_grid((5, 5))
    assert g.adjacency_matrix.nnz == 24
    assert g.n_points == 25
    g = PointUndirectedGraph.init_2d_grid((5, 5))
    assert g.adjacency_matrix.nnz == 80
    assert g.n_points == 25
    g = PointDirectedGraph.init_2d_grid((5, 5))
    assert g.adjacency_matrix.nnz == 80
    assert g.n_points == 25
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:12,代码来源:test_graph.py

示例2: test_init_2d_grid_custom_adjacency

# 需要导入模块: from menpo.shape import PointUndirectedGraph [as 别名]
# 或者: from menpo.shape.PointUndirectedGraph import init_2d_grid [as 别名]
def test_init_2d_grid_custom_adjacency():
    tree_adj = np.array([[0, 1, 0, 0],
                         [0, 0, 0, 1],
                         [0, 0, 0, 0],
                         [0, 0, 1, 0]])
    g = PointTree.init_2d_grid((2, 2), root_vertex=0, adjacency_matrix=tree_adj)
    assert g.adjacency_matrix.nnz == 3
    assert g.n_points == 4
    single_edge = lil_matrix((25, 25))
    single_edge[[0, 1], [1, 0]] = 1
    single_edge = single_edge.tocsr()
    g = PointUndirectedGraph.init_2d_grid(
        (5, 5), adjacency_matrix=single_edge)
    assert g.adjacency_matrix.nnz == 2
    assert g.n_points == 25
    g = PointDirectedGraph.init_2d_grid(
        (5, 5), adjacency_matrix=single_edge)
    assert g.adjacency_matrix.nnz == 2
    assert g.n_points == 25
开发者ID:AshwinRajendraprasad,项目名称:menpo,代码行数:21,代码来源:test_graph.py


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