Self-wiring of neural networks