(n, nc, ratio, P)
| 47 | |
| 48 | |
| 49 | def get_sbm(n, nc, ratio, P): |
| 50 | nbpc = np.round(n * ratio).astype(int) |
| 51 | n = np.sum(nbpc) |
| 52 | C = np.zeros((n, n)) |
| 53 | for c1 in range(nc): |
| 54 | for c2 in range(c1 + 1): |
| 55 | if c1 == c2: |
| 56 | for i in range(np.sum(nbpc[:c1]), np.sum(nbpc[: c1 + 1])): |
| 57 | for j in range(np.sum(nbpc[:c2]), i): |
| 58 | if rng.rand() <= P[c1, c2]: |
| 59 | C[i, j] = 1 |
| 60 | else: |
| 61 | for i in range(np.sum(nbpc[:c1]), np.sum(nbpc[: c1 + 1])): |
| 62 | for j in range(np.sum(nbpc[:c2]), np.sum(nbpc[: c2 + 1])): |
| 63 | if rng.rand() <= P[c1, c2]: |
| 64 | C[i, j] = 1 |
| 65 | |
| 66 | return C + C.T |
| 67 | |
| 68 | |
| 69 | n = 100 |
no test coverage detected