fixed prims algorithm and partial implementation for dfs