in step the edge with the minimum weight is removed from the priority queue this edge and its destination vertex are added to the treeand the source vertex (currentvertand destination vertex are displayed at the end of mstw()the vertices are removed from the tree by resetting their isintree variables that isn' strictly necessary in this programbecause only one tree is created from the data howeverit' good housekeeping to restore the data to its original form when you finish with it as we notedthe priority queue should contain only one edge with given destination vertex the putinpq(method makes sure this is true it calls the find(method of the priorityq classwhich has been doctored to find the edge with specified destination vertex if there is no such vertexand find(therefore returns - then putinpq(simply inserts the edge into the priority queue howeverif such an edge does existputinpq(checks to see whether the existing edge or the new proposed edge has the lower weight if it' the old edgeno change is necessary if the new one has lower weightthe old edge is removed from the queue and the new one is installed here' the code for putinpq()public void putinpq(int newvertint newdist/is there another edge with the same destination vertexint queueindex thepq find(newvert)/got edge' index if(queueindex !- /if there is one/get edge edge tempedge thepq peekn(queueindex)int olddist tempedge distanceif(olddist newdist/if new edge shorterthepq removen(queueindex)/remove old edge edge theedge new edge(currentvertnewvertnewdist)thepq insert(theedge)/insert new edge /else no actionjust leave the old vertex there /end if else /no edge with same destination vertex /so insert new one edge theedge new edge(currentvertnewvertnewdist)thepq insert(theedge)/end putinpq(the mstw java program the priorityq class uses an array to hold the members as we notedin program dealing with large graphs heap would be more appropriate than the array shown here the priorityq class has been augmented with various methods it canas we've seenfind an edge with given destination vertex with find(it can also peek at an arbitrary member with peekn(and remove an arbitrary member with removen(most of the rest of this program you've seen before listing shows the complete mstw java program