def cluster_transform_matrices(clustering): Q = np.zeros([len(clustering), clustering.n], np.float) for (idx, center) in enumerate(clustering.clusters): Q[idx, np.array(list(center.elements))] = 1.0 Qi = Q.T Q = markov.make_markov_row_stoch(Q) return Q, Qi
def cluster_transform(diffusion, clustering): Q = np.zeros([len(clustering), diffusion.shape[0]], np.float) for (idx, center) in enumerate(clustering.clusters): Q[idx, np.array(list(center.elements))] = 1.0 Qi = Q.T Q = markov.make_markov_row_stoch(Q) return Q.dot(diffusion).dot(Qi)