Let me walk through a sample input step by step. You will see how Prim's algorithm selects points, updates distances, and builds the MST. I'll show the priority queue state at each iteration. You will see which point is added and how the total cost grows with each selection.
This walkthrough clarifies how Prim works on implicit graphs. Watch how distances are computed on the fly instead of being pre-stored in a list.