I've a graph in Adjacency matrix format and the graph has disconnected trees. I need to find the MST of each disconnected tree. So should I first find subgraph for each tree and then use MST on the tree or is there a better approach/algorithm ?
I think I've found it.
Kruskal's algorithm and Borůvka's algorithm can find the minimum spanning forest in a possibly disconnected graph; in contrast, the most basic form of Prim's algorithm only finds minimum spanning trees in connected graphs.
However, running Prim's algorithm separately for each connected component of the graph, it can also be used to find the minimum spanning forest