/**
* Edge.java
*
*
* Created: Fri Mar 31 09:31:36 2000
*
* @author Hans Kyndesgaard
* @version 1
*/
public class Edge {
Node from;
Node to;
Locator fromLocator;
Locator toLocator;
/** Creates an edge from the from-node to the to-node.
Even though the two nodes are adjacent an edge will be made
between them. O(1).
@param from The origin of the newly created edge.
@param to The destination of the newly created edge.
*/
public Edge(Node from, Node to) {
this.from = from;
this.to = to;
fromLocator = from.out.insertLast(this);
toLocator = to.in.insertLast(this);
}
/** Removes this edge. The data structures int the nodes are updated accordingly. O(1).
*/
public void remove(){
from.out.remove(fromLocator);
to.in.remove(toLocator);
}
/** Produce a stringrepresentation of a edge. This is just a pair of node representations. (O(1).)
*/
public String toString(){
return "(" + from + ", " + to + ")";
}
} // Edge