Does the Prim algorith always create the same tree despite the starting node?

127 Views Asked by At

Does the Prim algorith always create the same tree despite the starting node?

PD: sorry for my english.

1

There are 1 best solutions below

0
On BEST ANSWER

When the weights are all different, the minimum spanning tree is unique. So, in this case, yes. In the general case, it depends on how you break ties.

Try Prim's algorithm on the vertices and edges of a square to see what happens with ties.