Preparing heap-based O(mlogn) Prim's algorithm