import java.util.Enumeration; /** A representation of a node. Created: Fri Mar 31 09:16:17 2000 @author Hans Kyndesgaard @version 1 */ public class Node { Sequence out = new Sequence(); Sequence in = new Sequence(); /* The name of the node. */ String name = ""; /* The rank used by the toLaTeX method in BipartiteGraph. */ int rankLaTeX = 0; String color = "white"; Edge prev = null; /** Creates a new Node. @param name You can give each node a name. This name can be very handy when debugging. <i>O</i>(<i>1</i>). */ public Node(String name, int rankLaTeX) { this.name = name; this.rankLaTeX = rankLaTeX; } /** Get the outgoing edges. @return an enumeration of all the edges going out of <code>this</code> node. <i>O</i>(<i>1</i>). */ public Enumeration outEdges() { return out.elements(); } /** Returns a random outgoing edge. @return an outgoing edge. <i>O</i>(<i>1</i>). */ public Edge anyOutEdge() { return (Edge)out.elements().nextElement(); } /** Get the incoming edges. @return an enumeration of all the edges going in to <code>this</code> node. <i>O</i>(<i>1</i>). */ public Enumeration inEdges() { return in.elements(); } /** Returns a random incoming edge. @return an incoming edge. <i>O</i>(<i>1</i>). */ public Edge anyInEdge() { return (Edge)in.elements().nextElement(); } /** Get the number of incoming edges. @return the number of edges going into <code>this</code> node. <i>O</i>(<i>1</i>). */ public int inDegree(){ return in.size(); } /** Get the number of outgoing edges. @return the number of edges going out of <code>this</code> node. <i>O</i>(<i>1</i>) */ public int outDegree(){ return out.size(); } /** The string representation is just the given name. <i>O</i>(<i>1</i>) */ public String toString(){ return name + " [" + color.charAt(0) + "]"; } } // Node