genericized network handling code and added dynamic random networks