Prim’s algorithm uses a greedy algorithm to discover the minimum cost spanning tree for a connected weighted undirected graph. As a result of this algorithm, a tree that includes all the vertex points and a subset of both edges is constructed in such a way that all the parameters associated…