Only compute similarity if two cls are connected.