int distance adjmat[currentvert][ ]ifdistance =infinity/skip if no edge continueputinpq(jdistance)/put it in pq (maybeif(thepq size()== /no vertices in pqsystem out println(graph not connected")return/remove edge with minimum distancefrom pq edge theedge thepq removemin()int sourcevert theedge srcvertcurrentvert theedge destvert/display edge from source to current system out printvertexlist[sourcevertlabel )system out printvertexlist[currentvertlabel )system out print(")/end while(not all verts in tree/mst is complete for(int = <nvertsj++/unmark vertices vertexlist[jisintree false/end mstw(the algorithm is carried out in the while loopwhich terminates when all vertices are in the tree within this loop the following activities take place the current vertex is placed in the tree the edges adjacent to this vertex are placed in the priority queue (if appropriate the edge with the minimum weight is removed from priority queue the destination vertex of this edge becomes the current vertex let' look at these steps in more detail in step the currentvert is placed in the tree by marking its isintree field in step the edges adjacent to this vertex are considered for insertion in the priority queue the edges are examined by scanning across the row whose number is currentvert in the adjacency matrix an edge is placed in the queue unless one of these conditions is truethe source and destination vertices are the same the destination vertex is in the tree there is no edge to this destination if none of these conditions is truethe putinpq(method is called to put the edge in the priority queue actuallythis routine doesn' always put the edge in the queue eitheras