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

Function generate_graph

tests/python/common/function/test_basics.py:57–92  ·  view source on GitHub ↗

s, d, eid 0, 1, 0 1, 9, 1 0, 2, 2 2, 9, 3 0, 3, 4 3, 9, 5 0, 4, 6 4, 9, 7 0, 5, 8 5, 9, 9 0, 6, 10 6, 9, 11 0, 7, 12 7, 9, 13 0, 8, 14 8, 9, 15 9, 0, 16

(idtype, grad=False)

Source from the content-addressed store, hash-verified

55
56
57def generate_graph(idtype, grad=False):
58 """
59 s, d, eid
60 0, 1, 0
61 1, 9, 1
62 0, 2, 2
63 2, 9, 3
64 0, 3, 4
65 3, 9, 5
66 0, 4, 6
67 4, 9, 7
68 0, 5, 8
69 5, 9, 9
70 0, 6, 10
71 6, 9, 11
72 0, 7, 12
73 7, 9, 13
74 0, 8, 14
75 8, 9, 15
76 9, 0, 16
77 """
78 u = F.tensor([0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 9])
79 v = F.tensor([1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9, 0])
80 g = dgl.graph((u, v), idtype=idtype)
81 assert g.device == F.ctx()
82 ncol = F.randn((10, D))
83 ecol = F.randn((17, D))
84 if grad:
85 ncol = F.attach_grad(ncol)
86 ecol = F.attach_grad(ecol)
87
88 g.ndata["h"] = ncol
89 g.edata["w"] = ecol
90 g.set_n_initializer(dgl.init.zero_initializer)
91 g.set_e_initializer(dgl.init.zero_initializer)
92 return g
93
94
95def test_compatible():

Callers 5

test_batch_setter_getterFunction · 0.70
test_apply_nodesFunction · 0.70
test_apply_edgesFunction · 0.70
test_update_routinesFunction · 0.70

Calls 4

set_n_initializerMethod · 0.80
set_e_initializerMethod · 0.80
graphMethod · 0.45
ctxMethod · 0.45

Tested by

no test coverage detected