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

Function create_test_heterograph2

tests/python/common/test_subgraph.py:148–171  ·  view source on GitHub ↗

test heterograph from the docstring, with an empty relation

(idtype)

Source from the content-addressed store, hash-verified

146
147
148def create_test_heterograph2(idtype):
149 """test heterograph from the docstring, with an empty relation"""
150 # 3 users, 2 games, 2 developers
151 # metagraph:
152 # ('user', 'follows', 'user'),
153 # ('user', 'plays', 'game'),
154 # ('user', 'wishes', 'game'),
155 # ('developer', 'develops', 'game')
156
157 g = dgl.heterograph(
158 {
159 ("user", "follows", "user"): ([0, 1], [1, 2]),
160 ("user", "plays", "game"): ([0, 1, 2, 1], [0, 0, 1, 1]),
161 ("user", "wishes", "game"): ([0, 2], [1, 0]),
162 ("developer", "develops", "game"): ([], []),
163 },
164 idtype=idtype,
165 device=F.ctx(),
166 )
167 for etype in g.etypes:
168 g.edges[etype].data["weight"] = F.randn((g.num_edges(etype),))
169 assert g.idtype == idtype
170 assert g.device == F.ctx()
171 return g
172
173
174@unittest.skipIf(

Callers 1

test_uva_subgraphFunction · 0.70

Calls 2

ctxMethod · 0.45
num_edgesMethod · 0.45

Tested by

no test coverage detected