code: public void updateDistance(int p, int q) {
          float d = linkage.d(p, q);
  
          if (d < distance[p]) {
              distance[p] = q;
              neighbor[p] = q;
          } else if (neighbor[p] == q && d > distance[p]) {
              findNeighbor(p);
          }
  
          if (d < distance[q]) {
              distance[q] = p;
              neighbor[q] = p;
          } else if (neighbor[q] == p && d > distance[q]) {
              findNeighbor(q);
          }
      }
docs: Single distance has changed, check if our structures are ok.