if(mindist =infinity/if all infinite /or in treesystem out println("there are unreachable vertices")break/spath is complete else /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()contents /display spath[ntree /clear tree for(int = <nvertsj++vertexlist[jisintree false/end path(/public int getmin(/get entry from spath /with minimum distance int mindist infinity/assume minimum int indexmin for(int = <nvertsj++/for each vertex/if it' in tree and if!vertexlist[jisintree &/smaller than old one spath[jdistance mindist mindist spath[jdistanceindexmin /update minimum /end for return indexmin/return index of minimum /end getmin(/public void adjust_spath(/adjust values in shortest-path array spath