MCPcopy Index your code
hub / github.com/dmlc/dgl / tree2

Function tree2

tests/python/common/test_batch-graph.py:30–47  ·  view source on GitHub ↗

Generate a tree 1 / \ 4 3 / \ 2 0 Edges are from leaves to root.

(idtype)

Source from the content-addressed store, hash-verified

28
29
30def tree2(idtype):
31 """Generate a tree
32 1
33 / \
34 4 3
35 / \
36 2 0
37 Edges are from leaves to root.
38 """
39 g = dgl.graph(([], [])).astype(idtype).to(F.ctx())
40 g.add_nodes(5)
41 g.add_edges(2, 4)
42 g.add_edges(0, 4)
43 g.add_edges(4, 1)
44 g.add_edges(3, 1)
45 g.ndata["h"] = F.tensor([0, 1, 2, 3, 4])
46 g.edata["h"] = F.randn((4, 10))
47 return g
48
49
50@parametrize_idtype

Callers 5

test_batch_unbatchFunction · 0.85
test_batch_unbatch1Function · 0.85
test_batch_unbatch_frameFunction · 0.85
test_batch_send_and_recvFunction · 0.85
test_batch_propagateFunction · 0.85

Calls 6

toMethod · 0.45
astypeMethod · 0.45
graphMethod · 0.45
ctxMethod · 0.45
add_nodesMethod · 0.45
add_edgesMethod · 0.45

Tested by

no test coverage detected