For Graph networks :param adj: A N x N adjacency matrix :return: In-degree normalized matrix (Row-normalized matrix)
(adj: np.ndarray)
| 16 | |
| 17 | |
| 18 | def in_degree_normalization(adj: np.ndarray): |
| 19 | """ |
| 20 | For Graph networks |
| 21 | :param adj: A N x N adjacency matrix |
| 22 | :return: In-degree normalized matrix (Row-normalized matrix) |
| 23 | """ |
| 24 | rowsum = np.array(adj.sum(1)) |
| 25 | r_inv = np.power(rowsum, -1).flatten() |
| 26 | r_inv[np.isinf(r_inv)] = 0.0 |
| 27 | r_mat_inv = np.diag(r_inv) |
| 28 | mx = r_mat_inv @ adj |
| 29 | return mx |
| 30 | |
| 31 | |
| 32 |
nothing calls this directly
no outgoing calls
no test coverage detected