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 graphsa 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 listing the mstw java program /mstw java /demonstrates minimum spanning tree with weighted graphs /to run this programc>java mstwapp ///////////////////////////////////////////////////////////////class edge public int srcvert/index of vertex starting edge public int destvert/index of vertex ending edge