A small imbalance can grow
Divide a large volume into many little boxes. Put slightly more matter in a few of them. That excess changes the gravitational pull on their neighbours. Matter flows towards the denser places, increasing the original difference. A local departure from the average density is called a density fluctuation.
All this happens in an expanding universe. Early on, two pieces of matter may still move apart, but more slowly than the average expansion would carry them. As an overdense region grows, gravity can eventually turn it around into actual contraction. An expanding background and local gravitational gathering can coexist.
Attraction alone does not yet explain the shape. We need to know which neighbours approach fastest and which directions keep extending. Those differences determine whether a region becomes flattened or elongated.
Reading: Zel’dovich (1970), Gravitational instability: an approximate theory for large density perturbations
A patch can flatten along one direction
Draw a box around neighbouring pieces of matter. An extra acceleration shared by every part moves the box as a whole. To change its shape, the pull must differ from one side to the other. This difference is a tidal effect. It can compress one direction while another contracts more slowly or stretches.
Suppose the box first becomes thin from top to bottom, leaving the other two directions extended. Matter gathers near a sheet. Compression along another direction can leave an elongated structure. This is a local account of deformation; it does not impose one construction schedule on the entire universe.
In 1970, Zel’dovich described an approximation in which the initial gravitational pattern sets the displacement directions and a growing factor increases the displacements. It gives a particularly clear picture of unequal compression, including the point at which the map first folds.
Reading: Zel’dovich (1970), Gravitational instability: an approximate theory for large density perturbations · Original finite-mesh calculations and independent small-wave Python replay
The network remembers a wider pattern
The web is not assembled by joining independently collapsing boxes at random. Gravity at one place depends on matter distributed over a much wider neighbourhood. The positions of neighbouring dense regions correlate the directions of motion in different patches.
Bond, Kofman and Pogosyan emphasised this connection in their 1996 work. Broad, weak precursors of the later filaments were already present in the initial density and tidal patterns. Nearby peaks with suitably aligned deformations supported stronger connecting bridges; greater separation or misalignment weakened the connection. Nonlinear evolution sharpened the pattern.
A local sheet-like fold therefore tells only part of the story. The arrangement of sheets, filaments and nodes also carries the spatial relationships in the initial fluctuations. Matter flows away from other regions, leaving the web's emptier volumes. These voids still contain matter.
Reading: Bond, Kofman & Pogosyan, How filaments are woven into the cosmic web (1996), astro-ph/9512141v1
Streams can meet and keep moving
A common approximation treats cold dark matter as collisionless. Direct encounters between particles are negligible, allowing streams to pass through one another. Gravity continues changing their velocities, but there is no gas shock in this description to stop the streams at their meeting place.
Label the original layers of matter. Initially, a location belongs to one stream. Later, different labels can reach the same place. This is shell crossing. The name does not require spherical shells: parallel planes can cross too. Each label still follows its own matter, but working backwards from a location can now give several answers.
A density picture adds those streams together. Adding velocity separates them: one stream can move left as another moves right. The combined description of position and velocity is called phase space. A dense knot in an image can contain matter that is still moving rapidly in several directions.
The displacement approximation can continue drawing a folded map. Following the later gravitational motion also requires the force to respond to the changed density. A particle-mesh calculation repeatedly deposits the matter, solves for gravity and advances the motion. Keeping the velocities lets us follow the overlapping streams into what happens next.
Reading: Zel’dovich (1970), Gravitational instability: an approximate theory for large density perturbations · Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1