algo2: first edge extracted
algo2: O(m*n) Prim's algorithm implemented