def _optimize(self, n_nodes, adjacency_norm, probs_out, probs_in): """One local optimization pass of the Louvain algorithm Parameters ---------- n_nodes : the number of nodes in the adjacency adjacency_norm : the norm of the adjacency probs_out : the array of degrees of the adjacency probs_in : the array of degrees of the transpose of the adjacency Returns ------- labels : the communities of each node after optimization pass_increase : the increase in modularity gained after optimization """ node_probs_in = probs_in node_probs_out = probs_out adjacency = 0.5 * directed2undirected(adjacency_norm) self_loops = adjacency.diagonal() indptr: np.ndarray = adjacency.indptr indices: np.ndarray = adjacency.indices data: np.ndarray = adjacency.data return fit_core(self.resolution, self.tol, n_nodes, node_probs_out, node_probs_in, self_loops, data, indices, indptr)
def _optimize(self, adjacency_norm, probs_ou, probs_in): """One local optimization pass of the Louvain algorithm Parameters ---------- adjacency_norm : the norm of the adjacency probs_ou : the array of degrees of the adjacency probs_in : the array of degrees of the transpose of the adjacency Returns ------- labels : the communities of each node after optimization pass_increase : the increase in modularity gained after optimization """ node_probs_in = probs_in.astype(np.float32) node_probs_ou = probs_ou.astype(np.float32) adjacency = 0.5 * directed2undirected(adjacency_norm) self_loops = adjacency.diagonal().astype(np.float32) indptr: np.ndarray = adjacency.indptr.astype(np.int32) indices: np.ndarray = adjacency.indices.astype(np.int32) data: np.ndarray = adjacency.data.astype(np.float32) return fit_core(self.resolution, self.tol, node_probs_ou, node_probs_in, self_loops, data, indices, indptr)