Prim-Jarnik Algorithm