def set_affinity_matrix(self, affinity_mat):
affinity_mat = check_array(affinity_mat, accept_sparse=sparse_formats)<EOL>if affinity_mat.shape[<NUM_LIT:0>] != affinity_mat.shape[<NUM_LIT:1>]:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>self.affinity_matrix = affinity_mat<EOL>
Parameters
----------
affinity_mat : sparse matrix (N_obs, N_obs).
    The adjacency matrix to input.