vectorization of adj_helper_gen