package algorithms; import java.util.Vector; /* A GraphNode has a stored value (type String), a reference to a list of * adjacent nodes, and a "count" variable to help with implementing graph search. */ public class GraphNode { // data members String value; // string info stored at node Vector next; // vector of references to adjacent nodes int count; // can be used to implement graph searching // constructor for a node with a given "count" value // string is set to "", and there are no adjacent nodes public GraphNode(int count) { value = ""; next = new Vector(); this.count = count; } // no-arg constructor // string is set to "", count to 0, and there are no adjacent nodes public GraphNode() { this(0); // call to 1-arg constructor } // accessor for value public String getValue() { return value; } // accessor for next public Vector getNext() { return next; } // accessor for count public int getCount() { return count; } // mutator for value public void setValue(String v) { value = v; } // returns the degree of this node public int degree() { if(next == null) return 0; else return next.size(); } // method to check if an edge exists public boolean isAdjacent(GraphNode h) { if(this.next == null) return false; for(int i=0; i"); else // get info about all the nodes adjacent to this node { int i; for(i=0; i