failed attempt at kruskals implementation