Instead of using for loop to get the geodist, i.e. : solver.compute_distance(i), return N \times 1. Can directly return the matrix of N \times N.