构造MST
2017-11-05 本文已影响0人
98Future
Version1
Version2:
我在做的时候有点卡在如何加速runtime了。。一开始没想到要用PriorityQueue
然后就发现非常难找到smallest cost edge that points to a vertex in included regions.
Time Complexity of the above program is O(V^2). If the input graph is represented using adjacency list, then the time complexity of Prim’s algorithm can be reduced to O(E log V) with the help of binary heap.
reason: