Structure of trophic and mutualistic networks across broad environmental gradients