kruskal works; implemented a hash function to convert string to int input