  We calculate by means of the Press-Schechter formalism the density profile
developed by dark-matter halos during accretion, i.e., the continuous
aggregation of small clumps. We find that the shape of the predicted profile is
similar to that shown by halos in high-resolution cosmological simulations.
Furthermore, the mass-concentration relation is correctly reproduced at any
redshift in all the hierarchical cosmologies analyzed, except for very large
halo masses. The role of major mergers, which can cause the rearrangement of
the halo structure through violent relaxation, is also investigated. We show
that, as a result of the boundary conditions imposed by the matter continuously
infalling into the halo during the violent relaxation process, the shape of the
density profile emerging from major mergers is essentially identical to the
shape the halo would have developed through pure accretion. This result
explains why, according to high-resolution cosmological simulations, relaxed
halos of a given mass have the same density profile regardless of whether they
have had a recent merger or not, and why both spherical infall and hierarchical
assembly lead to very similar density profiles. Finally, we demonstrate that
the density profile of relaxed halos is not affected either by the capture of
clumps of intermediate mass.
