local connectivity function for hopfield