MCPcopy
hub / github.com/dmlc/dgl / tree1

Function tree1

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

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

(idtype)

Source from the content-addressed store, hash-verified

8
9
10def tree1(idtype):
11 """Generate a tree
12 0
13 / \
14 1 2
15 / \
16 3 4
17 Edges are from leaves to root.
18 """
19 g = dgl.graph(([], [])).astype(idtype).to(F.ctx())
20 g.add_nodes(5)
21 g.add_edges(3, 1)
22 g.add_edges(4, 1)
23 g.add_edges(1, 0)
24 g.add_edges(2, 0)
25 g.ndata["h"] = F.tensor([0, 1, 2, 3, 4])
26 g.edata["h"] = F.randn((4, 10))
27 return g
28
29
30def tree2(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