package Graph; public class Vertex implements Comparable { public String id; public int distance; public Vertex prev; public Vertex(String id, int distance, Vertex prev) { this.id = id; this.distance = distance; this.prev = prev; } public String toString() { return id; } @Override public int compareTo(Vertex other) { return this.distance - other.distance; } @Override public boolean equals(Object other) { return other instanceof Vertex && ((Vertex) other).id.equals(this.id); } @Override public int hashCode() { return id.hashCode(); } }