Prim
Refactoring Prim algorithm