code for generating neighborhoods