docs: protected void mergeRegions() {
  
  		// sort edges
  //		long time0 = System.currentTimeMillis();
  		if( sorterApprox != null ) {
  			sorterApprox.computeRange(edges.data,0,edges.size);
  			sorterApprox.sortObject(edges.data,0,edges.size);
  		} else {
  			sorter.sort(edges.data,edges.size);
  		}
  //		long time1 = System.currentTimeMillis();
  
  //		System.out.println("Sort time " + (time1 - time0));
  
  		// examine each edge to see if it can connect two regions
  		for( int i = 0; i < edges.size(); i++ ) {
  			// compare the two nodes connected by the edge to see if their regions they should be merged
  			Edge e = edges.get(i);
  
  			int rootA = find(e.indexA);
  			int rootB = find(e.indexB);
  
  			// see if they are already part of the same segment
  			if( rootA == rootB )
  				continue;
  
  			float threshA = threshold.get(rootA);
  			float threshB = threshold.get(rootB);
  
  			if( e.weight() <= threshA && e.weight() <= threshB )  {
  				// ----- Merge the two regions/components
  				int sizeA = regionSize.get(rootA);
  				int sizeB = regionSize.get(rootB);
  
  				// Everything is merged into region A, so update its threshold
  				threshold.data[rootA] = e.weight() + K/(sizeA + sizeB);
  
  				// Point everything towards rootA
  				graph.data[e.indexB] = rootA;
  				graph.data[rootB] = rootA;
  
  				// Update the size of regionA
  				regionSize.data[rootA] = sizeA + sizeB;
  			} else {
  				edgesNotMatched.add(e);
  			}
  		}
  
  //		long time2 = System.currentTimeMillis();
  //		System.out.println("Edge merge time " + (time2 - time1));
  	}