chap graphs edge list function next will return value of |vonce the end of the edge list for has been reached the following line appears in many graph algorithmsfor ( =>first( ) () ->next( , )this for loop gets the first neighbor of vthen works through the remaining neighbors of until value equal to -> (is returnedsignaling that all neighbors of have been visited for examplefirst( in figure would return next( would return next( would return next( would return which is not vertex in the graph it is reasonably straightforward to implement our graph and edge adts using either the adjacency list or adjacency matrix the sample implementations presented here do not address the issue of how the graph is actually created the user of these implementations must add functionality for this purposeperhaps reading the graph description from file the graph can be built up by using the setedge function provided by the adt figure shows an implementation for the adjacency matrix array mark stores the information manipulated by the setmark and getmark functions the edge matrix is implemented as an integer array of size for graph of vertices position (ijin the matrix stores the weight for edge (ijif it exists weight of zero for edge (ijis used to indicate that no edge connects vertices and given vertex vfunction first locates the position in matrix of the first edge (if anyof by beginning with edge ( and scanning through row until an edge is found if no edge is incident on vthen first returns function next locates the edge following edge (ij(if anyby continuing down the row of vertex starting at position looking for an edge if no such edge existsnext returns functions setedge and deledge adjust the appropriate value in the array function weight returns the value stored in the appropriate position in the array figure presents an implementation of the adjacency list representation for graphs its main data structure is an array of linked listsone linked list for each vertex these linked lists store objects of type edgewhich merely stores the index for the vertex pointed to by the edgealong with the weight of the edge