Implement mimilarity measure function and enumeration function