(
idtype, dtype, ctx, M, N, max_nnz, srctype, dsttype, etype
)
| 13 | |
| 14 | |
| 15 | def _random_simple_graph( |
| 16 | idtype, dtype, ctx, M, N, max_nnz, srctype, dsttype, etype |
| 17 | ): |
| 18 | src = np.random.randint(0, M, (max_nnz,)) |
| 19 | dst = np.random.randint(0, N, (max_nnz,)) |
| 20 | val = np.random.randn(max_nnz) |
| 21 | a = ssp.csr_matrix((val, (src, dst)), shape=(M, N)) |
| 22 | a.sum_duplicates() |
| 23 | a = a.tocoo() |
| 24 | # shuffle edges |
| 25 | perm = np.random.permutation(a.nnz) |
| 26 | row = a.row[perm] |
| 27 | col = a.col[perm] |
| 28 | val = a.data[perm] |
| 29 | a = ssp.csr_matrix((val, (row, col)), shape=(M, N)) |
| 30 | |
| 31 | A = dgl.heterograph( |
| 32 | { |
| 33 | (srctype, etype, dsttype): ( |
| 34 | F.copy_to(F.tensor(row, dtype=idtype), ctx), |
| 35 | F.copy_to(F.tensor(col, dtype=idtype), ctx), |
| 36 | ) |
| 37 | }, |
| 38 | num_nodes_dict={srctype: a.shape[0], dsttype: a.shape[1]}, |
| 39 | ) |
| 40 | A.edata["w"] = F.copy_to(F.tensor(val, dtype=dtype), ctx) |
| 41 | return a, A |
| 42 | |
| 43 | |
| 44 | @parametrize_idtype |
no test coverage detected