// This code is from "Algorithms in Java, Third Edition," // by Robert Sedgewick, Addison-Wesley, 2003. // See p. 231 class Edge //implements Item // ADT interface { // implementations and private members hidden private int tail; private int head; private double weight; Edge(int tail, int head, double weight) { this.tail=tail; this.head=head; this.weight=weight; } public int v() { return tail; } public int w() { return head; } double wt() { return weight; } boolean from(int x) { return x==v(); } int other(int x) { if (from(x)) return w(); return v(); } public boolean less(Edge x) { if (this.tailx.v()) return false; return this.head" + head + " wt " + weight; } }