// This is a code fragment in the C programming language. // The coordinates for point i are stored as double (floating-point) numbers // in the entries x[i], y[i], z[i]. // When C converts a double to an int (that is, integer), it rounds the value // down. To obtain the TSPLIB rounding to the nearest integer, we add 0.5 to // the square-root value before casting it to an int. int euclid3d_edgelen (int i, int j) { double t1 = x[i] - x[j], t2 = y[i] - y[j], t3 = z[i] - z[j]; return (int) (sqrt (t1 * t1 + t2 * t2 + t3 * t3) + 0.5); }