Reputation: 1307
Can we compute the maximal spanning tree by changing the algorithm to choosing the maximum vertex instead of choosing the minimum one?
I have come across the solution by negating the edges and applying the normal Prim's Minimum Spanning Tree algorithm.
Upvotes: 0
Views: 3729
Reputation: 76297
Feed in to the algorithm the input graph, but with the weights negated. Nothing in Prim assumes the weights are positive. The minimum of the weights negated, is achieved by the maximum of the original weights.
Upvotes: 1