priority queue implementation and faster prim version