assignment F - Kruskal's algorithm: heap + union find