Using Priority Queue/Min-Heap: O(V + E) V is the number of vertices. E is the number of edges. In addition to storing the graph itself, the algorithm uses additional space for maintaining the priority queue or min-heap. The space complexity is considered reasonable, making it practical ...
Learn how to implement a Swift minimum spanning tree using Prim’s algorithm, in this step by step tutorial.