On the Optimal Communication Weights in Distributed Optimization Algorithms