Fixed critical bug on Prim Algorithm