implemented kruskals