简体   繁体   中英

Prim's Algorithm and disconnected graph

Consider we are trying to apply prim's algorithm on a disconnected graph. Consider that this disconnected graph has vertices a,b,c and d. Where this vertex d is disconnected. Now I need to check my understanding, if we apply prim's algorithm on this disconnected graph, the algorithm will not reach the vertex d and therefore will return a MST with vertices a,b and c only. So, is this assumption right ?

While it is true that the actual definition of MST applies to connected graphs, you could also say that, for a disconnected graph, a minimum spanning forest is composed of a minimum spanning tree for each connected component.

The problem adds an initial step to isolate each connected sub-graph, and apply Prim's algorithm to each of these.

There's no point in applying a Minimum Spanning Tree on a disconnected graph because by definition it is disconnected and it will not span all the vertices. By definition it is relevant only to connected graphs:

A minimum spanning tree (MST) or minimum weight spanning tree is a subset of the edges of a connected , edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight.

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