fast_tsp.is_valid_dist_matrix

fast_tsp.is_valid_dist_matrix(dists)

Returns a string describing the error if the distance matrix is invalid, otherwise returns None. Checks the following: - The distance matrix is non-empty. - The distance matrix is 2D and square. - The distance matrix contains only non-negative integers. - The distance matrix contains only integers that fit in a uint16. - The diagonal is 0. - The distance matrix is symmetric. - The distance matrix satisfies the triangle inequality.

Uses numpy when it is installed and a pure-Python fallback otherwise.

Return type:

str | None