fixed bug in Prim's algorithm (source was always set to 0)