import java.util.*; public class myWeightedGraph { protected String[] names; // 1-d array to store the vertices protected EdgeLinkList[] Edges; // 1-d array to store edges between vertices and weights protected int numVertices; protected int numEdges; // Constructor that sets aside as much capacity as specified by the user public myWeightedGraph(int capacity) { names = new String[capacity]; Edges = new EdgeLinkList[capacity]; for (int i = 0 ; i < capacity ; i ++) { Edges[i] = new EdgeLinkList(); } } // Finds the location at which a vertex is stored in Vertices. // Returns -1 if vertex not found public int getIndex(String vertex) { for(int i = 0; i < numVertices; i++) if(vertex.equals(names[i])) return i; return -1; } // Adds a new vertex public void addVertex(String newVertex) { if(getIndex(newVertex) != -1) { System.out.print("addVertex: "); System.out.print(newVertex); System.out.println(" failed -- vertex already exists."); return; } names[numVertices++] = newVertex; } // Adds a new edge between vertex1 and vertex2 with the given weight w public void addEdge(String vertex1, String vertex2, double w) { // Missing code should go here } // Get the weight of the edge connecting vertex1 to vertex2 and return it // as a Double object; return null is there is no edge between vertex1 and // vertex2 Double getWeight(String vertex1, String vertex2) { // Missing code should go here } } // end of class