简体   繁体   中英

Graph algorithms: Prim

I was wondering if any minimum spanning tree of a graph G can be provided by an execution of the algorithm Prim on this graph?

Does the Prim algorithm give us all the possible MST?

I was wondering if any minimum spanning tree of a graph G can be provided by an execution of the algorithm Prim on this graph?

Yes.

Prim's algorithm is known to be a good algorithm to find a minimum spanning tree.

Since Prim's algorithm constructs a MST from a weighted, connected, undirected graph, yes, you can use it to get a minimum spanning tree from such a graph. If your graph is not connected it won't work (but neither will any other algorithm because there is no spanning tree, then). If your graph is not weighted it will just create a spanning tree.

If you use Prim's once to get a MST then delete an edge. Then use prim's again to see if you can still get a MST of the same length. If you do, repeat, otherwise put the edge back and remove another edge. It will be slowish ... Perhaps only remove heavy edges?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM