Prim-Jarník algorithm