code: private static double edgelength(double[][] matrix, int[] edges, int i) {
      i <<= 1;
      return matrix[edges[i]][edges[i + 1]];
    }
docs: Length of edge i.
  
  @param matrix Distance matrix
  @param edges Edge list
  @param i Edge number
  @return Edge length