Question: Like the Kruskal's algorithm, Prim's algorithm is a well - known algorithm to determine minimum spanning trees on a graph. For this question, you will

Like the Kruskal's algorithm, Prim's algorithm is a well-known algorithm to determine minimum spanning trees on a graph. For this question, you will illustrate the working of the Prim's algorithm on a graph assigned to you. You should illustrate the working of the algorithm through a sequence of iterations (as shown in Example Graphs 1 and 2).
The high-level description of the Prim's algorithm is as follows:
Step 1: Initialize the tree with a single vertex, chosen arbitrarily from the graph. Initialize the set of candidate edges with the edges connecting the vertex in the tree to the vertices that are not yet in the tree.
Step 2: Grow the tree by one edge: Among the edges (referred to as the candidate edges) that connect the vertices in the tree to the vertices that are not yet in the tree, find the edge of the minimum weight and transfer it to tree (if two or more candidate edges are of the same minimum weight, break the tie arbitrarily).
Step 3: Update the set of candidate edges as follows:
Include the edges (if any) that are between the recently included vertex in the tree (from Step 2) and to vertices that are not yet in the tree
Exclude the candidate edges (if any) that are between the recently included vertex in the tree (from Step 2) and to vertices that are already in the tree.
Step 4: Repeat Steps 2 and 3 until all the vertices in the tree.
The working of the above algorithm is illustrated below on two example graphs.
In each iteration, the candidate edges are shown in dotted lines and the tree edges are shown in bold lines.
Also, the vertices that are included in the tree are highlighted in yellow and the vertices that are not yet in the tree are not highlighted.
You should show similar work on the graph assigned to you. Example Graph 1
Example Graph 2
Like the Kruskal's algorithm, Prim's algorithm is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!