def test_prop_nodes_bfs(idtype): g = dgl.graph(nx.path_graph(5), idtype=idtype, device=F.ctx()) g.ndata['x'] = F.ones((5, 2)) dgl.prop_nodes_bfs(g, 0, message_func=mfunc, reduce_func=rfunc, apply_node_func=None) # pull nodes using bfs order will result in a cumsum[i] + data[i] + data[i+1] assert F.allclose(g.ndata['x'], F.tensor([[2., 2.], [4., 4.], [6., 6.], [8., 8.], [9., 9.]]))
def test_prop_nodes_bfs(): g = dgl.DGLGraph(nx.path_graph(5)) g.ndata['x'] = th.ones((5, 2)) g.register_message_func(mfunc) g.register_reduce_func(rfunc) dgl.prop_nodes_bfs(g, 0) # pull nodes using bfs order will result in a cumsum[i] + data[i] + data[i+1] assert U.allclose(g.ndata['x'], th.tensor([[2., 2.], [4., 4.], [6., 6.], [8., 8.], [9., 9.]]))
def test_prop_nodes_bfs(): g = dgl.DGLGraph(nx.path_graph(5)) g.ndata['x'] = mx.nd.ones(shape=(5, 2)) g.register_message_func(mfunc) g.register_reduce_func(rfunc) dgl.prop_nodes_bfs(g, 0) # pull nodes using bfs order will result in a cumsum[i] + data[i] + data[i+1] assert np.allclose( g.ndata['x'].asnumpy(), np.array([[2., 2.], [4., 4.], [6., 6.], [8., 8.], [9., 9.]]))