Optimizing the Structure of Diffusion Networks: Theory and Algorithms