Categories
Mastering Development

How could I give in Kruskal’s algorithm the name of the locations (vertex) in the form of strings, more precisely city names?

I wrote the following code with Kruskal’s algorithm and I don’t know how to modify it so that the locations are city names. public class Vertex { public char value; private char[] alphabet = {‘A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’}; public Vertex(char val) { this.value = val; } public int getIndex() { int idx = new String(alphabet).indexOf(this.value); return idx; } […]