本文整理汇总了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
示例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