(self)
| 288 | ) |
| 289 | |
| 290 | def process(self): |
| 291 | if self.seed is not None: |
| 292 | random.seed(self.seed) |
| 293 | np.random.seed(self.seed) |
| 294 | |
| 295 | # Construct two BA-SHAPES graphs |
| 296 | g1 = BAShapeDataset( |
| 297 | self.num_base_nodes, |
| 298 | self.num_base_edges_per_node, |
| 299 | self.num_motifs, |
| 300 | self.perturb_ratio, |
| 301 | force_reload=True, |
| 302 | verbose=False, |
| 303 | )[0] |
| 304 | g2 = BAShapeDataset( |
| 305 | self.num_base_nodes, |
| 306 | self.num_base_edges_per_node, |
| 307 | self.num_motifs, |
| 308 | self.perturb_ratio, |
| 309 | force_reload=True, |
| 310 | verbose=False, |
| 311 | )[0] |
| 312 | |
| 313 | # Join them and randomly add edges between them |
| 314 | g = batch([g1, g2]) |
| 315 | num_nodes = g.num_nodes() // 2 |
| 316 | src = np.random.randint(0, num_nodes, (self.num_inter_edges,)) |
| 317 | dst = np.random.randint( |
| 318 | num_nodes, 2 * num_nodes, (self.num_inter_edges,) |
| 319 | ) |
| 320 | src = F.astype(F.zerocopy_from_numpy(src), g.idtype) |
| 321 | dst = F.astype(F.zerocopy_from_numpy(dst), g.idtype) |
| 322 | g.add_edges(src, dst) |
| 323 | g.ndata["label"] = F.cat( |
| 324 | [g1.ndata["label"], g2.ndata["label"] + 4], dim=0 |
| 325 | ) |
| 326 | |
| 327 | # feature generation |
| 328 | random_mu = [0.0] * 8 |
| 329 | random_sigma = [1.0] * 8 |
| 330 | |
| 331 | mu_1, sigma_1 = np.array([-1.0] * 2 + random_mu), np.array( |
| 332 | [0.5] * 2 + random_sigma |
| 333 | ) |
| 334 | feat1 = np.random.multivariate_normal(mu_1, np.diag(sigma_1), num_nodes) |
| 335 | |
| 336 | mu_2, sigma_2 = np.array([1.0] * 2 + random_mu), np.array( |
| 337 | [0.5] * 2 + random_sigma |
| 338 | ) |
| 339 | feat2 = np.random.multivariate_normal(mu_2, np.diag(sigma_2), num_nodes) |
| 340 | |
| 341 | feat = np.concatenate([feat1, feat2]) |
| 342 | g.ndata["feat"] = F.zerocopy_from_numpy(feat) |
| 343 | self._graph = reorder_graph( |
| 344 | g, |
| 345 | node_permute_algo="rcmk", |
| 346 | edge_permute_algo="dst", |
| 347 | store_ids=False, |
nothing calls this directly
no test coverage detected