2. SPANNING TREE
A spanning tree of an undirected graph is a
subgraph that includes all the vertices of the
original graph connected with the minimum
number of edges, ensuring no cycles are
present.
3. MINIMUM SPANNING TREE
Given a connected, undirected graph G=(V,E) with weighted edges, a
Minimum Spanning Tree is a spanning tree that:
Connects all vertices: Ensures there is a path between any pair of
nodes.
Is acyclic: Contains no cycles, maintaining the tree structure.
Has minimal total edge weight: The sum of the weights of its edges is
the smallest among all possible spanning trees of the graph.
For a graph with v vertices, any spanning tree, including the MST, will
have exactly (V−1) edges.
Definition
5. PROPERTIES:MST
Uniqueness: If all edge weights are distinct, the MST is unique.
Multiple MSTs: If edge weights are not unique, there may be
multiple MSTs with the same total weight.
Cycle Property: For any cycle in the graph, the edge with
the highest weight in that cycle does not belong to the MST.
Cut Property: For any cut in the graph, the edge with the
smallest weight crossing the cut is included in the MST.
7. KRUSKAL’S ALGORITHM
Below are the steps for finding MST using Kruskal’s algorithm:
Sort all the edges in a non-decreasing order of their
weight.
Pick the smallest edge. Check if it forms a cycle with the
spanning tree formed so far. If the cycle is not formed,
include this edge. Else, discard it.
Repeat step 2 until there are (V-1) edges in the spanning
tree.
9. Greedy Approach: Selects the smallest-weight edge that
doesn't form a cycle to construct the Minimum Spanning Tree
(MST).
Edge-Centric: Emphasizes edges rather than vertices, making it
particularly effective for sparse graphs.
Cycle Detection: Uses the Union-Find data structure to efficiently
merge disjoint sets and prevent cycles.
Time Complexity: Runs in O(E log V) time, thanks to edge sorting
and near-constant time Union-Find operations.
Key Characteristics
10. PRIM’S ALGORITHM
The steps how prim’s algorithm works are below:
Choose a starting point – Pick any vertex to begin, like 0.
Find new connections – Look at all the vertices not yet included in
the tree.
Check available edges – Find edges connecting the tree to those
new vertices.
Pick the smallest edge – Choose the edge with the least weight.
Add it to the tree – Bring the connected vertex into the growing MST.
Since we only add edges that connect new vertices, there are no
loops.
Repeat until done – Keep adding edges until all vertices are
included, then return the final MST.
12. Greedy approach – Always selects the smallest edge.
Incremental growth – Expands the MST one edge at a time.
No cycles – Ensures an acyclic spanning tree.
Works with weighted graphs – Requires a connected,
weighted, undirected graph.
Efficient with priority queue – Optimized using a min-heap.
Time complexity – Runs in O(V²) with an adjacency matrix, or
O(E log V) with a priority queue.
Key Characteristics
14. APPLICATIONS OF MST
Internet & Network Connections – Helps design cost-effective
layouts for laying cables and setting up Wi-Fi networks.
Road Planning – Used to find the shortest way to connect cities or
towns with minimal road length.
Electricity Distribution – Helps power companies create efficient
grids to supply electricity with fewer cables.
Water Supply Systems – Used to design pipeline networks that
connect homes and cities with minimal material cost.
Cluster Analysis in AI – Helps group similar data points, like
organizing images or sorting customer preferences.