/**** * * GraphInterface defines constructive methods for building a graph. The Graph * class of Assignment 6 must implement this interface. *

* As an example of using these methods, the following sequence of calls * constructs the directed graph in Figure 9.1 on page 292 of the textbook: *

 *    Graph g = new Graph();
 *
 *    g.addNode("1").
 *      addNode("2").
 *      addNode("3").
 *      addNode("4").
 *      addNode("5").
 *      addNode("6").
 *      addNode("7");
 *
 *    g.addEdge("1", "2", true).
 *      addEdge("1", "3", true).
 *      addEdge("1", "4", true).
 *      addEdge("2", "4", true).
 *      addEdge("2", "5", true).
 *      addEdge("3", "6", true).
 *      addEdge("4", "3", true).
 *      addEdge("4", "6", true).
 *      addEdge("4", "7", true).
 *      addEdge("5", "4", true).
 *      addEdge("5", "7", true).
 *      addEdge("7", "6", true);
 *                                                                       
* * @author Gene Fisher (gfisher@calpoly.edu) * @version 5jun01 * */ public interface GraphInterface { /** * Add a node of the given value to this. Do nothing if a node of the * given value is already in this. Return the updated or unchanged value * of this. */ public GraphInterface addNode(Comparable value); /** * Add an unweighted edge between the nodes of the given values in this. * Do nothing if the nodes are not in this or if there is an existing edge * between the nodes. If the isDirected input is true, make the edge * directed from nodeValue1 to nodeValue2. If is isDirected is false, add * the edge as undirected. Return the updated or unchanged value of this. */ public GraphInterface addEdge(Comparable nodeValue1, Comparable nodeValue2, boolean isDirected); /** * Add an edge of the given weight between the nodes of the given values in * this. Do nothing if the nodes are not in this or if there is an * existing edge between the nodes. If the isDirected input is true, make * the edge directed from nodeValue1 to nodeValue2. If is isDirected is * false, add the edge as undirected. Return the updated or unchanged * value of this. */ public GraphInterface addEdge(Comparable nodeValue1, Comparable nodeValue2, int weight, boolean isDirected); }