/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 the work is done in the while loopwhich continues until the number of vertices is reduced to here are the steps involved call nosuccessors(to find any vertex with no successors if such vertex is foundput the vertex label at the end of sortedarray[and delete the vertex from graph if an appropriate vertex isn' foundthe graph must have cycle the last vertex to be removed appears first on the listso the vertex label is placed in sortedarray starting at the end and working toward the beginningas nverts (the number of vertices in the graphgets smaller if vertices remain in the graph but all of them have successorsthe graph must have cycleand the algorithm displays message and quits if there are no cyclesthe while loop exitsand the list from sortedarray is displayedwith the vertices in topologically sorted order the nosuccessors(method uses the adjacency matrix to find vertex with no successors in the outer for loopit goes down the rowslooking at each vertex for each vertexit scans across the columns in the inner for looplooking for if it finds oneit knows that that vertex has successorbecause there' an edge from that vertex to another one when it finds it bails out of the inner loop so that the next vertex can be investigated only if an entire row is found with no do we know we have vertex with no successorsin this caseits row number is returned if no such vertex is found- is returned here' the nosuccessors(methodpublic int nosuccessors(/returns vert with no successors /(or - if no such verts