Function to calculate the similarity matrix based on the cluster membership indicator of each iteration.
Useful links