Minimum spanning tree using Prims algorithm
Minimum spanning tree using Prims algorithm
PRESENTATION
MINIMUM SPANNING TREE USING
PRIMS ALGORITHM
GROUP MEMBERS
SABA NOOR 21
KINZA ALI 04
WISHAH ZUBAIR 34
MINIMUM SPANING TREE USING
PRIMS ALGORITHM
A Minimum Spanning Tree (MST) of a
connected, undirected graph is a subgraph
that connects all the vertices together with
the minimum possible total edge weight and
without forming any cycles.
KEY POINTS:
• Spanning:
An MST must include all the vertices in the
original graph.
• Tree:
There are no cycles.
The graph remains connected.
Minimum Total Weight: The total sum of the
edge weights in the MST is minimized.
Prim’s Algorithm: A Solution for Finding MST
Greedy Approach:
Prim's algorithm works by continuously adding the minimum-weight edge that
connects a vertex inside the MST to a vertex outside of the MST.
Efficiency: Prim’s algorithm is efficient and works well for dense graphs
(graphs with many edges).
Telecommunications networks:
Minimizing the cost of laying cables or wires between
various locations.
Road network design:
Finding the least costly network of roads connecting cities.
Works for Dense Graphs:
Prim’s algorithm is especially useful for graphs with a large
number of edges (dense graphs).
Simple and Incremental:
It's easy to understand and implement, and it works
incrementally, growing the MST one edge at a time.
No need for global sorting:
Unlike Kruskal’s Algorithm, which requires sorting all edges
first, Prim's algorithm can avoid this by selecting edges on
the fly, making it efficient when implemented with the right
data structures.
Consider the following graph as an example for which we need to find the Minimum Spanning Tree (MST).
The final structure of the MST is as follows and the weight of the edges of the MST
is
(4 + 8 + 1 + 2 + 4 + 2 + 7 + 9) = 37.
WAYS TO IMPLEMENT PRIMS
ALGORITHM
1.The simplest approach uses an adjacency
matrix and an array, with a time complexity of
O(V²).
END FUNCTION