weights to distances