Open In App

What is Minimum Spanning Tree (MST)

A minimum spanning tree (MST) is defined as a spanning tree that has the minimum weight among all the possible spanning trees

A spanning tree is defined as a tree-like subgraph of a connected, undirected graph that includes all the vertices of the graph. Or, to say in Layman’s words, it is a subset of the edges of the graph that forms a tree (acyclic) where every node of the graph is a part of the tree.



The minimum spanning tree has all the properties of a spanning tree with an added constraint of having the minimum possible weights among all possible spanning trees. Like a spanning tree, there can also be many possible MSTs for a graph.



Properties of a Spanning Tree:

The spanning tree holds the below-mentioned principles:

Minimum Spanning Tree:

A minimum spanning tree (MST) is defined as a spanning tree that has the minimum weight among all the possible spanning trees.

The minimum spanning tree has all the properties of a spanning tree with an added constraint of having the minimum possible weights among all possible spanning trees. Like a spanning tree, there can also be many possible MSTs for a graph.

Minimum Spanning Tree

Algorithms to find Minimum Spanning Tree:

There are several algorithms to find the minimum spanning tree from a given graph, some of them are listed below:

Kruskal’s Minimum Spanning Tree Algorithm:

This is one of the popular algorithms for finding the minimum spanning tree from a connected, undirected graph. This is a greedy algorithm. The algorithm workflow is as below:

This algorithm can be implemented efficiently using a DSU ( Disjoint-Set ) data structure to keep track of the connected components of the graph. This is used in a variety of practical applications such as network design, clustering, and data analysis.

Follow the article on “Kruskal’s Minimum Spanning Tree Algorithm” for a better understanding and implementation of the algorithm.

Prim’s Minimum Spanning Tree Algorithm:

This is also a greedy algorithm. This algorithm has the following workflow:

To efficiently select the minimum weight edge for each iteration, this algorithm uses priority_queue to store the vertices sorted by their minimum edge weight currently. It also simultaneously keeps track of the MST using an array or other data structure suitable considering the data type it is storing.

This algorithm can be used in various scenarios such as image segmentation based on color, texture, or other features. For Routing, as in finding the shortest path between two points for a delivery truck to follow.

Follow the article on “Prim’s Minimum Spanning Tree Algorithm” for a better understanding and implementation of this algorithm.

Boruvka’s Minimum Spanning Tree Algorithm:

This is also a graph traversal algorithm used to find the minimum spanning tree of a connected, undirected graph. This is one of the oldest algorithms. The algorithm works by iteratively building the minimum spanning tree, starting with each vertex in the graph as its own tree. In each iteration, the algorithm finds the cheapest edge that connects a tree to another tree, and adds that edge to the minimum spanning tree. This is almost similar to the Prim’s algorithm for finding the minimum spanning tree. The algorithm has the following workflow:

The algorithm can be implemented using a data structure such as a priority queue to efficiently find the cheapest edge between trees. Boruvka’s algorithm is a simple and easy-to-implement algorithm for finding minimum spanning trees, but it may not be as efficient as other algorithms for large graphs with many edges.

Follow the article on “Boruvka’s Minimum Spanning Tree Algorithm” for a better understanding and implementation of this algorithm.

To knowing more about the properties and characteristics of Minimum Spanning Tree, click here.

Applications of Minimum Spanning Trees:

Some popular interview problems on MST

1. Find the Minimum Cost to Connect All Cities Practice
2. Detect Cycle in an Undirected Graph Practice
3. Bridge in a Graph Practice
4. Minimum Product Spanning Tree Practice
5. Maximum Spanning Tree using Kruskal’s Algorithm Practice
6. Second Minimum Spanning Tree Practice
7. Steiner Tree Practice
8. Find the weight of the minimum spanning tree Practice
9. Second Best Minimum Spanning Tree Practice
10. Minimum spanning tree cost of given Graphs Practice

Some FAQs about Minimum Spanning Trees:

1. Can there be multiple minimum-spanning trees for a given graph?

Yes, a graph can have multiple minimum spanning trees if there are multiple sets of edges with the same minimum total weight.

2. Can Kruskal’s algorithm and Prim’s algorithm be used for directed graphs?

No, Kruskal’s algorithm and Prim’s algorithm are designed for undirected graphs only.

3. Can a disconnected graph have a minimum spanning tree?

No, a disconnected graph cannot have a spanning tree because it does not span all the vertices. Therefore, it also cannot have a minimum spanning tree.

4. Can a minimum spanning tree be found using Dijkstra’s algorithm?

No, Dijkstra’s algorithm is used to find the shortest path between two vertices in a weighted graph. It is not designed to find a minimum spanning tree.

5. What is the time complexity of Kruskal’s and Prim’s algorithms?

Both Kruskal’s and Prim’s algorithms have a time complexity of O(ElogE), where E is the number of edges in the graph.


Article Tags :