In supernova cores, nuclear "pasta" phases such as a triangular lattice of rodlike nuclei and layered structure of slablike nuclei are considered to exist. However, it is still unclear whether or not they are actually formed in collapsing supernova cores. Using ab initio simulations called quantum molecular dynamics, here we solve this problem by demonstrating that a lattice of rodlike nuclei is formed from a bcc lattice by compression. We also find that, in the transition process, the system undergoes a zigzag configuration of elongated nuclei, which are formed by a fusion of two original spherical nuclei.