Upgrade gr_get_neighbors function