private static double thresholdLength(double[][] matrix, int[] edges) {
    double[] lengths = new double[edges.length >> 1];
    for(int i = 0, e = edges.length - 1; i < e; i += 2) {
      lengths[i >> 1] = matrix[edges[i]][edges[i + 1]];
    }
    Arrays.sort(lengths);
    final int pos = (lengths.length >> 1); // 50%
    return lengths[pos];
  }
private static double thresholdLength ( double [ ] [ ] matrix , int [ ] edges ) { double [ ] lengths = new double [ edges . length > > 1 ] ; for ( int i = 0 , e = edges . length - 1 ; i < e ; i += 2 ) { lengths [ i > > 1 ] = matrix [ edges [ i ] ] [ edges [ i + 1 ] ] ; } Arrays . sort ( lengths ) ; final int pos = ( lengths . length > > 1 ) ; return lengths [ pos ] ; }
Choose the threshold length of edges to consider omittig.

@param matrix Distance matrix
@param edges Edges
@return Distance threshold