Learn Before
Concept

Prim Algorithm

Prim's Algorithm is a greedy algorithm ( since it chooses the most optimal next step) that finds the minimum spanning tree by adding one vertex at a time. It begins with an empty spanning tree that gets initialized with a vertex from a graph. At each step, it finds the minimum - weight edge out of the edges that are not already in the tree and moves the edge to the minimum spanning tree.

It can use a priority queue to add a vertex to the minimum spanning tree since it is typically more efficient at finding the vertex with a minimum - weight edge than using a linked list or other data structure.

0

1

Updated 2021-05-18

Tags

Python Programming Language

Data Science