public void path(/find all shortest paths int starttree /start at vertex vertexlist[starttreeisintree truentree /put it in tree /transfer row of distances from adjmat to spath for(int = <nvertsj++int tempdist adjmat[starttree][ ]spath[jnew distpar(starttreetempdist)/until all vertices are in the tree while(ntree nvertsint indexmin getmin()/get minimum from spath int mindist spath[indexmindistanceif(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()/display spath[contents ntree /clear tree for(int = <nvertsj++vertexlist[jisintree false/end path(