Function determines structure in complex neural networks