graphs later we'll discuss when to use an adjacency matrix as opposed to an adjacency list the workshop applets shown in this all use the adjacency matrix approachbut sometimes the list approach is more efficient adding vertices and edges to graph to add vertex to graphyou make new vertex object with new and insert it into your vertex arrayvertexlist in real-world program vertex might contain many data itemsbut for simplicity we'll assume that it contains only single character thusthe creation of vertex looks something like thisvertexlist[nverts++new vertex(' ')this inserts vertex fwhere nverts is the number of vertices currently in the graph how you add an edge to graph depends on whether you're using an adjacency matrix or adjacency lists to represent the graph let' say that you're using an adjacency matrix and want to add an edge between vertices and these numbers correspond to the array indices in vertexlist where the vertices are stored when you first created the adjacency matrix adjmatyou filled it with to insert the edgeyou say adjmat[ ][ adjmat[ ][ if you were using an adjacency listyou would add to the list for and to the list for the graph class let' look at class graph that contains methods for creating vertex list and an adjacency matrixand for adding vertices and edges to graph objectclass graph private final int max_verts private vertex vertexlist[]/array of vertices private int adjmat[][]/adjacency matrix private int nverts/current number of vertices /public graph(/constructor vertexlist new vertex[max_verts]/adjacency matrix adjmat new int[max_verts][max_verts]