force diagonal to be 0 for distances