Here you can find the source of distances(double[][] arr, int[][] partners)
public static double[] distances(double[][] arr, int[][] partners)
//package com.java2s; //License from project: Open Source License public class Main { public static double[] distances(double[][] arr, int[][] partners) { double[] res = new double[partners.length]; for (int i = 0; i < res.length; i++) { res[i] = distance(arr[partners[i][0]], arr[partners[i][1]]); }/* w ww. ja va 2 s .c o m*/ return (res); } /** returns distance between two points*/ public static double distance(double[] v1, double[] v2) { double dx = v1[0] - v2[0]; double dy = v1[1] - v2[1]; double dz = v1[2] - v2[2]; return (Math.sqrt(dx * dx + dy * dy + dz * dz)); } }