We should be able to skip the following cases `i==j` and `distance[i, j] == distance[j, i]`.