prim-jarnik algorithm in the prim-jarnik algorithmwe grow minimum spanning tree from single cluster starting from some "rootvertex the main idea is similar to that of dijkstra' algorithm we begin with some vertex sdefining the initial "cloudof vertices thenin each iterationwe choose minimum-weight edge (uv)connecting vertex in the cloud to vertex outside of the vertex is then brought into the cloud and the process is repeated until spanning tree is formed againthe crucial fact about minimum spanning trees comes into playfor by always choosing the smallest-weight edge joining vertex inside to one outside cwe are assured of always adding valid edge to the mst to efficiently implement this approachwe can take another cue from dijkstra' algorithm we maintain label [vfor each vertex outside the cloud cso that [vstores the weight of the minimum observed edge for joining to the cloud (in dijkstra' algorithmthis label measured the full path length from starting vertex to vincluding an edge (uvthese labels serve as keys in priority queue used to decide which vertex is next in line to join the cloud we give the pseudo-code in code fragment algorithm primjarnik( )inputan undirectedweightedconnected graph with vertices and edges outputa minimum spanning tree for pick any vertex of [ for each vertex  do [vinitialize initialize priority queue with an entry ( [ ](vnone)for each vertex vwhere [vis the key in the priority queueand (vnoneis the associated value while is not empty do (uevalue returned by remove min(connect vertex to using edge for each edge (uvsuch that is in do {check if edge (uvbetter connects to if (uvd[vthen [vw(uvchange the key of vertex in to [vchange the value of vertex in to (ve return the tree code fragment the prim-jarnik algorithm for the mst problem