Prim's MST with a Heap
Grow the tree from one vertex.
A Different Path to the MST
Prim's algorithm also finds a minimum spanning tree, but it grows one connected blob outward instead of sorting all the edges first. 🌱
Grow From One Vertex
Pick any starting vertex and mark it as visited. The tree begins as a single node and expands one edge at a time.
visited = [False] * nAll lessons in this course
- DSU with Path Compression
- Union by Rank and Components
- Kruskal's Minimum Spanning Tree
- Prim's MST with a Heap