I was thinking that Prim's algorithm won't work with a disjointed graph. But maybe it doesn't have to.
When we're asking to find the minimum spanning tree of a graph, is it implicit that the graph will always be connected?
I was thinking that Prim's algorithm won't work with a disjointed graph. But maybe it doesn't have to.
When we're asking to find the minimum spanning tree of a graph, is it implicit that the graph will always be connected?
Ya , you have to assume that because it is a minimum spanning tree. A Tree is directed, acyclic and connected graph. So if there are separate components in graph. You can form a forest(Collection of trees) of minimum spanning tree but it cannot be called as a single MST.