listing continued system out println("errorgraph has cycles")return/insert vertex label in sorted array (start at endsortedarray[nverts- vertexlist[currentvertexlabeldeletevertex(currentvertex)/end while /delete vertex /vertices all gonedisplay sortedarray system out print("topologically sorted order")for(int = <orig_nvertsj++system out printsortedarray[ )system out println("")/end topo /public int nosuccessors(/returns vert with no successors /(or - if no such vertsboolean isedge/edge from row to column in adjmat for(int row= row<nvertsrow++/for each vertexisedge false/check edges for(int col= col<nvertscol++ifadjmat[row][col /if edge to /anotherisedge truebreak/this vertex /has successor /try another if!isedge /if no edgesreturn row/has no successors return - /no such vertex /end nosuccessors(/public void deletevertex(int delvertif(delvert !nverts- /if not last vertex