Exemple #1
0
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
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
Exemple #3
0
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
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