[Verse 1]
Graph problems need connections, minimum spanning tree
Start with any vertex, mark it naturally
Build a priority queue, edges weighted clean
Greedy algorithm, leanest path machine
Pick the smallest edge that doesn't form a cycle
Add it to your forest, keep the process vital
Repeat until vertices minus one complete
Prim's delivers optimal, never obsolete
[Chorus]
Start anywhere, priority queue prepared
Lightest edge that connects what's not yet shared
No cycles allowed, forest growing proud
Minimum spanning tree, algorithm crowned
Edge by edge we climb, optimal every time
Prim's the name, spanning trees our claim
[Verse 2]
Initialize your distance array to infinity
Mark your starting node as zero, set it free
While unvisited vertices remain in sight
Extract the minimum distance, bring to light
Relax all adjacent edges, update the cost
If lighter path discovered, previous one's lost
Fibonacci heap boost performance to the max
Logarithmic operations, efficiency facts
[Chorus]
Start anywhere, priority queue prepared
Lightest edge that connects what's not yet shared
No cycles allowed, forest growing proud
Minimum spanning tree, algorithm crowned
Edge by edge we climb, optimal every time
Prim's the name, spanning trees our claim
[Bridge]
Dense graphs favor Prim's approach
Adjacency matrix, direct reproach
Time complexity depends on structure choice
Array implementation gives it voice
Binary heap runs in E log V
Dense networks where Prim's runs free
[Verse 3]
Cut property guarantees we're making progress right
Minimum weight crossing cut illuminates the sight
Visited set grows larger with each iteration round
Unvisited shrinks smaller, optimal solution found
Network design and clustering, real world applications
Telecommunications calling, infrastructure foundations
[Outro]
From single source expanding, minimum cost connecting
Prim's algorithm commanding, optimal tree selecting
Priority queue directing, greedy choice perfecting
Minimum spanning tree, algorithmically protecting