0% found this document useful (0 votes)
14 views9 pages

6627 DM

Uploaded by

Harinath Eega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views9 pages

6627 DM

Uploaded by

Harinath Eega
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Introduction to Prims

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

1 O(E log V) 2 Efficient Implementation 3 Compared to Kruskal


The time complexity of Prims By using a priority queue, the Prims algorithm is generally
algorithm is O(E log V), where E algorithm can efficiently select more efficient than Kruskal's
is the number of edges and V is the cheapest available edge at algorithm, especially for dense
the number of vertices in the each step, leading to the graphs, as it avoids the need
graph. optimal time complexity. for sorting all the edges.
Applications of Prims Algorithm
Network Design Facility Location
Prims algorithm is widely used in It can be used to determine the
network design to connect all nodes optimal locations for facilities, such as
with the minimum cost of cables or warehouses or power plants, to
communication links. minimize the overall transportation or
distribution costs.

Roadway Planning Image Segmentation


In transportation planning, Prims Prims algorithm has applications in
algorithm can help identify the optimal computer vision, where it can be used
routes to connect cities or towns with for image segmentation by grouping
the least total road construction cost. pixels into meaningful regions.
Comparison to Kruskal's Algorithm
Approach Time Complexity Applications

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

You might also like