Fix bug in disjoint set that didn't update ranks and didn't create a circular linked list