def test_compute_roles(): """ test_node_roles """ # TODO explicit assert test community_vect = read_lol_file(lol_file) node_corres, sparse_matrix = read_Pajek_corres_nodes_and_sparse_matrix( Pajek_net_file) val = compute_roles(community_vect, sparse_matrix, role_type='4roles') print(val)
def _run_interface(self, runtime): rada_lol_file = self.inputs.rada_lol_file Pajek_net_file = self.inputs.Pajek_net_file print('Loading Pajek_net_file for reading node_corres') node_corres, sparse_mat = read_Pajek_corres_nodes_and_sparse_matrix( Pajek_net_file) print(sparse_mat.todense()) print(node_corres.shape, sparse_mat.todense().shape) print("Loading community belonging file " + rada_lol_file) community_vect = read_lol_file(rada_lol_file) print(community_vect) print("Computing node roles") node_roles, all_Z_com_degree, all_participation_coeff = compute_roles( community_vect, sparse_mat, role_type=self.inputs.role_type) node_roles_file = os.path.abspath('node_roles.txt') np.savetxt(node_roles_file, node_roles, fmt='%d') all_Z_com_degree_file = os.path.abspath('all_Z_com_degree.txt') np.savetxt(all_Z_com_degree_file, all_Z_com_degree, fmt='%f') all_participation_coeff_file = os.path.abspath( 'all_participation_coeff.txt') np.savetxt(all_participation_coeff_file, all_participation_coeff, fmt='%f') if self.inputs.compute_ndi: ndi_values = compute_node_dissociation_index( community_vect, sparse_mat) ndi_values_file = os.path.abspath('ndi_values.txt') np.savetxt(ndi_values_file, ndi_values, fmt='%f') return runtime