code: private void remap() {
          int k = -1;
          for (int i = 0; i < map.length; i++) {
              boolean found = false;
  
              for (int j = k + 1; j < links.length; j++) {
                  if (links[j] != null) {
                      found = true;
                      k = j;
                      map[i] = k;
                      break;
                  }
              }
  
              if (found) {
                  continue;
              }
  
              for (int j = 0; j < k; j++) {
                  if (links[j] != null) {
                      found = true;
                      k = j;
                      map[i] = k;
                      break;
                  }
              }
  
              if (!found) {
                  map[i] = 0;
              }
          }
      }
docs: This method is called each time when number of links has changed to reestablish relation between link selection indicator
  and link