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

Function create_test_heterograph

tests/python/common/test_subgraph.py:122–145  ·  view source on GitHub ↗
(idtype)

Source from the content-addressed store, hash-verified

120
121
122def create_test_heterograph(idtype):
123 # test heterograph from the docstring, plus a user -- wishes -- game relation
124 # 3 users, 2 games, 2 developers
125 # metagraph:
126 # ('user', 'follows', 'user'),
127 # ('user', 'plays', 'game'),
128 # ('user', 'wishes', 'game'),
129 # ('developer', 'develops', 'game')])
130
131 g = dgl.heterograph(
132 {
133 ("user", "follows", "user"): ([0, 1], [1, 2]),
134 ("user", "plays", "game"): ([0, 1, 2, 1], [0, 0, 1, 1]),
135 ("user", "wishes", "game"): ([0, 2], [1, 0]),
136 ("developer", "develops", "game"): ([0, 1], [0, 1]),
137 },
138 idtype=idtype,
139 device=F.ctx(),
140 )
141 for etype in g.etypes:
142 g.edges[etype].data["weight"] = F.randn((g.num_edges(etype),))
143 assert g.idtype == idtype
144 assert g.device == F.ctx()
145 return g
146
147
148def create_test_heterograph2(idtype):

Callers 2

test_subgraph_maskFunction · 0.70
test_subgraph1Function · 0.70

Calls 2

ctxMethod · 0.45
num_edgesMethod · 0.45

Tested by

no test coverage detected