Page 1 of 1

7. As shown in the following figures, Prim's algorithm is usually used to find the minimum spanning tree, in which the i

Posted: Mon Jun 06, 2022 6:48 pm
by answerhappygod
7 As Shown In The Following Figures Prim S Algorithm Is Usually Used To Find The Minimum Spanning Tree In Which The I 1
7 As Shown In The Following Figures Prim S Algorithm Is Usually Used To Find The Minimum Spanning Tree In Which The I 1 (53.25 KiB) Viewed 37 times
7. As shown in the following figures, Prim's algorithm is usually used to find the minimum spanning tree, in which the intermediate set of edges X always forms a subtree, and S is chosen to be the set of this tree's vertices. On each iteration, the subtree defined by X grows by one edge, namely the lightest edge between a vertex in S and a vertex outside S. Draw a table to show the changes of cost and prev values, and construct the final Minimum Spanning Tree. (15) 8 4 A F 2 2 2 D 1 2 10 G B 16 E H 2 procedure prim (G,w) Input: A connected undirected graph G=(V.E) with edge weights we Output: A minimum spanning tree defined by the array prev for all we V cost(N) = x prev(s)-nil Pick any initial node a cost(m)-0 H-makequeue (V) (priority queue, using cost-values as keys) while H is not empty: e=deletemin(H) for each (r.) E. if cost(s) > wr, 2); cost(s) = (v.) prev(s) decreasekey(H.:)