Prim-Jarnik algorithm for the minimum spanning tree problem