We have used a combination of high resolution cosmological N-body simulatio
ns and semianalytic modelling of galaxy formation to investigate the proces
ses that determine the spatial distribution of galaxies in cold dark matter
(CDM) models and its relation to the spatial distribution of dark matter.
The galaxy distribution depends sensitively on the efficiency with which ga
laxies form in haloes of different mass. In small mass haloes, galaxy forma
tion is inhibited by the reheating of cooled gas by feedback processes, whe
reas in large mass haloes, it is inhibited by the long cooling time of the
gas. As a result, the mass-to-light ratio of haloes has a deep minimum at t
he halo mass, similar to 10(12) M., associated with L-* galaxies, where gal
axy formation is most efficient. This dependence of galaxy formation effici
ency on halo mass leads to a scale-dependent bias in the distribution of ga
laxies relative to the distribution of mass. On large scales, the bias in t
he galaxy distribution is related in a simple way to the bias in the distri
bution of massive haloes. On small scales, the correlation function is dete
rmined by the interplay between various effects including the spatial exclu
sion of dark matter haloes, the distribution function of the number of gala
xies occupying a single dark matter halo and, to a lesser extent, dynamical
friction. Remarkably, these processes,conspire to produce a correlation fu
nction in a flat, Ohm(0) = 0.3, CDM model that is close to a power law over
nearly four orders of magnitude in amplitude. This model agrees well with
the correlation function of galaxies measured in the automated-plate measur
ement survey. On small scales, the model galaxies are less strongly cluster
ed than the dark matter, whereas on large scales they trace the occupied ha
loes. Our clustering predictions are robust to changes in the parameters of
the galaxy formation model, provided only those models which match the bri
ght end of the galaxy luminosity function are considered.