6627 DM
6627 DM
Algorithm
Prims algorithm is a fundamental graph theory concept used to find the
minimum spanning tree (MST) of a connected, weighted graph. It starts
with a single vertex and gradually expands the tree by adding the
cheapest available edge that connects a vertex in the tree to a vertex
outside the tree.
Minimum Spanning Tree (MST)
The minimum spanning tree (MST) is a subset of the edges of a
a connected, edge-weighted graph that connects all the vertices
vertices together, without any cycles, and with the minimum possible
possible total edge weight. Prims algorithm is one of the most efficient
efficient ways to compute the MST of a graph.
Greedy Approach
Prims algorithm follows a greedy approach, where at each step it selects the cheapest available edge that connects a vertex in
connects a vertex in the current tree to a vertex outside the tree. This locally optimal choice eventually leads to the globally
the globally optimal minimum spanning tree.
Algorithm Steps
1 Start
Begin with a single vertex and mark it as part of the
growing tree.
2 Select Edge
Choose the cheapest edge that connects a vertex in the
tree to a vertex outside the tree.
3 Add Vertex
Add the new vertex to the tree and mark it as part of
the growing tree.
Edge Selection Criteria
Weight Cycle Avoidance Connectivity
The algorithm selects the edge with The selected edge must not create a The selected edge must connect the
the minimum weight that connects a cycle in the growing tree, ensuring growing tree to a vertex outside the
vertex in the tree to a vertex outside the final result is a true minimum tree, gradually expanding the overall
the tree. spanning tree. connectivity.
Time Complexity
Prims algorithm starts with a single Prims algorithm has a time Prims algorithm is better suited for
vertex and gradually expands the complexity of O(E log V), which is dense graphs, while Kruskal's
tree, while Kruskal's algorithm generally more efficient than algorithm is more efficient for sparse
begins with the individual vertices Kruskal's algorithm, which has a time graphs. Both have their own
and merges them into the tree. complexity of O(E log E). strengths and applications.
Thank you…!
Presented by :
Raju
22SS1A6627
CSM