/** * Class to implement a directed edge. * All values associated with an edge are final. * The only thing you can do is create the edge or delete the edge. * * Note clear that I really need the stuff here as it really only applies to the node. * But it does not hurt, or even particularly hinder * * @author geoffreytowell * * @param */ public class Edge { private final Node from; private final Node too; private final String id; private final int cost; /** * Create an edge with a default cost of 1. * @param f * @param t * @param id */ public Edge(Node f, Node t, String id) { this(f, t, id, 1); } public Edge(Node f, Node t, String id, int c) { from=f; too=t; this.id=id; this.cost = c; } public Node getFrom() { return from; } public NodegetToo() { return too; } public int getCost() { return this.cost; } public String toString() { return String.format("<%s %s-->%s c:%d>", this.id, from.toString(), too.toString(), cost); } }