import java.util.*; public class ListGraph { protected LinkedList M[]; // adjacency list protected int n; // number of vertices // Creates a graph with numVertex number of vertices by first creating an // array of numVertices empty linked lists, and then creating a new linked // lists for each of the vertices. public ListGraph (int numVertices) { n = numVertices; M = new LinkedList[n]; for (int i=0; i -1); } // returns number of nodes adjacent to node source public int outdegree(int source) { return M[source].size(); } // returns number of nodes adjacent to node source public int indegree(int destination) { int numIn = 0; for (int i=0; i -1) ? 1 : 0; return numIn; } // Returns the number of edges in the graph. public int numberEdges() { int numEdges = 0; for (int i=0; i