public int compareTo(Object o2) { Edge e2 = (Edge) o2; if (this.getWeight() < e2.getWeight()) return -1; else if (this.getWeight() > e2.getWeight()) return 1; else if (this.getWeight() == e2.getWeight()) return 0; return -2; }