Measuring the similarity between nodes