I was recently struggling with the best way to randomly construct a well-connected, recurrent topology of neurons until I encountered Percolation theory.
There is a basic natural log scaling rule that essentially guarantees that you will have a well-connected topology (even with random connections) as long as you ensure a minimum # of connections are assigned to each element.
The required fanout at each order of magnitude network size goes something like:
10: ~3 connections
100: ~5 connections
1,000: ~7 connections
10,000: ~10 connections
100,000: ~12 connections
1,000,000: ~14 connections
100,000,000,000: ~26 connections
I've been able to avoid a lot of complicated code by leveraging this.