/reset currentvert currentvert indexmin/to closest vert starttocurrent spath[indexmindistance/minimum distance from starttree is /to currentvertand is starttocurrent /put current vertex in tree vertexlist[currentvertisintree truentree++adjust_spath()/update spath[array /end while(ntree<nvertsdisplaypaths()/display spath[contents ntree /clear tree for(int = <nvertsj++vertexlist[jisintree false/end path(the starting vertex is always at index of the vertexlist[array the first task in path(is to put this vertex into the tree as the algorithm proceeds we'll be moving other vertices into the tree as well the vertex class contains flag that indicates whether vertex object is in the tree putting vertex in the tree consists of setting this flag and incrementing ntreewhich counts how many vertices are in the tree secondpath(copies the distances from the appropriate row of the adjacency matrix to spath[this is always row because for simplicity we assume is the index of the starting vertex initiallythe parent field of all the spath[entries is athe starting vertex we now enter the main while loop of the algorithm this loop terminates when all the vertices have been placed in the tree there are basically three actions in this loop choose the spath[entry with the minimum distance put the corresponding vertex (the column head for this entryin the tree this becomes the "current vertexcurrentvert update all the spath[entries to reflect distances from currentvert if path(finds that the minimum distance is infinityit knows that there are vertices that are unreachable from the starting point whybecause not all the vertices are in the tree (the while loop hasn' terminated)and yet there' no way to get to these extra verticesif there werethere would be non-infinite distance before returningpath(displays the final contents of spath[by calling the displaypaths(method this is the only output from the program alsopath(sets ntree to and removes the isintree flags from all the verticesin case they might be used again by another algorithm (although they aren' in this programfinding the minimum distance with getmin(to find the spath[entry with the minimum distancepath(calls the getmin(