Almost set up Kruskals algorithm