chap graphs public int weight(int iint /return edge weight return matrix[ ][ ]/get and set marks public void setmark(int vint valmark[vvalpublic int getmark(int vreturn mark[ ]figure (continued/edge class for adjacency list graph representation class edge private int vertwtpublic edge(int vint /constructor vert vwt wpublic int vertex(return vertpublic int weight(return wtimplementation for graphl member functions is straightforward in principlewith the key functions being setedgedeledgeand weight the simplest implementation would start at the beginning of the adjacency list and move along it until the desired vertex has been found howevermany graph algorithms work by taking advantage of the first and next functions to process all edges extending from given vertex in turn thusthere is significant time savings if setedgedeledgeand weight first check to see if the desired edge is the current one on the relevant linked list the implementation of figure does exactly this graph traversals often it is useful to visit the vertices of graph in some specific order based on the graph' topology this is known as graph traversal and is similar in concept to tree traversal recall that tree traversals visit every node exactly oncein some specified order such as preorderinorderor postorder multiple tree traversals exist because various applications require the nodes to be visited in particular order for exampleto print bst' nodes in ascending order requires an inorder traversal as opposed to some other traversal standard graph traversal orders also exist each is appropriate for solving certain problems for examplemany problems in artificial intelligence programming are modeled using graphs the problem domain may consist of large collection of stateswith connections between various pairs of states solving the problem may require getting from specified start state to