package tsp.shortestpath; public class Edge implements Comparable { private Location from; private Location to; public Edge (Location from, Location to){ this.from = from; this.to = to; } public Location getTo() { return to; } public Location getFrom() { return from; } public double getWeight(){ return this.from.distanceTo(this.to); } @Override public int compareTo(Edge edge) { double w1 = this.getWeight(); double w2 = edge.getWeight(); if (w1 < w2){ return -1; } else if (w1 == w2){ return 0; } else { return 1; } } @Override public String toString() { return "(" + this.from + " -> " + this.to + ")"; } }