went from O(N^2 log N) to O(N log N) in network generation