Not all galaxies are built alike.

There are spectacular, sparkling spirals with graceful arms curling elegantly out into space. There are small, indistinct blobs. There are strange rings with hollow centers or diffuse, dim collections of stars that barely look like a galaxy at all.

How galaxies get the way they do is something of a mystery. But new research has provided some answers.

Using a neural network, a team of Australian scientists uncovered how well-structured spiral galaxies change into fuzzy, featureless lenticular and elliptical galaxies with no arm structures to speak of.

In particular, the research sheds light on a previously unexplained odd phenomenon known as the morphology-density relation: Lone galaxies hanging out by themselves, like the Milky Way, are more likely to be spirals, while galaxies in clusters tend to be lenticular or elliptical.

How the neural network classified galaxies in the simulation. (ICRAR)

"We've discovered there are a few different things going on when we get lots of galaxies packed together," says astronomer Joel Pfeffer of the University of Western Australia node of the International Centre for Radio Astronomy Research (ICRAR).

"The spiral arms on galaxies are so fragile, and as you go to higher densities in the galaxy clusters, spiral galaxies start to lose their gas. This loss of gas causes them to 'drop' their spiral arms, transforming into a lenticular shape. Another cause is galaxy mergers, which can see two or more spiral galaxies crashing together to form one large elliptical galaxy in the aftermath."

The work used a project called Evolution and Assembly of GaLaxies and their Environments (EAGLE), a sophisticated simulation designed to further the understanding of galaxy formation and evolution.

Since EAGLE closely matches observations, scientists are confident that it accurately reflects the real evolution of the Universe. They use it as a laboratory in which they can observe changes that, in real-time, take way too long to be observed in action.

Researchers trained an algorithm to recognize galaxies based on their shapes and let it loose on the simulation. The algorithm identified 20,000 galaxies a minute, vastly reducing the time it would have taken to classify them in the simulation. They found that EAGLE accurately recreates the morphology-density relation seen in the real Universe.

Scientists could then observe the evolutionary paths that lead to the dominance of certain galaxy types in different environments. In high-density environments, gravitational interactions and collisions between galaxies alter the shapes of spiral galaxies to produce a larger number of lenticular and elliptical galaxies.

The neural network also identified occasional fuzzier galaxies in lower-density regions of space, too. The simulation showed that these occur when galaxies with a supermassive black hole at their respective centers merge. This alone isn't enough to change a galaxy's shape since, in low-density environments, spiral arms can re-form.

In these cases, the supermassive black holes play a key role. When they merge, they form an active galactic nucleus that provides what is known as feedback. Powerful winds and radiation from the extreme space around an actively feeding black hole blast through the galaxy, stripping away the intergalactic gas around that would otherwise replenish the galactic gas and curtailing its ability to re-form spiral arms.

The researchers say these mechanisms are all consistent with previous theories about how galaxies change over time, joining them in a larger picture of galactic interaction and evolution.

"There's been lots of suggestions over time," Pfeffer says. "But this is the first work to really put all of the pieces of the puzzle together."

The research has been published in the Monthly Notices of the Royal Astronomical Society.