The brightest cluster galaxies (BCG's) are the most luminous and massive galaxies in the universe. A typical BCG is located near the centre of its parent cluster and well-aligned with the cluster galaxy distribution suggesting that it lies at the bottom of the cluster's gravitational potential well. The general impression that stars have settled to the bottom of a pit suggests that the origin of BCG's is closely connected to the formation of the cluster. BCG's are elliptical galaxies that are much brighter and much more massive than the average with luminosities 10 L ( L), (e.g., Sandage & Hardy 1973; Schombert 1986; Brown 1997)  central velocity dispersions in the range km/s (e.g., Dressler 1979; Carter et al. 1985; Fisher, Illingworth & Franx 1995) and very little rotational support. Like other ellipticals, their light profile is well-described by a deVaucouleurs surface brightness law, over a large range in radii (deVaucouleurs 1948). The BCG's are variously classified as giant ellipticals (gE), as D galaxies which have somewhat shallower light profiles than E's and the final classification cD for D galaxies with an extended envelope of excess light over and above a deVaucouleurs law fit to the inner regions (Kormendy 1989). cD galaxies are also only found in the centres of clusters and groups so their extended envelope is probably associated with the formation of the cluster.
The following theories have been proposed to explain the origin of BCG's, i) star formation from cooling flows expected in the high density, rapidly cooling centres of cluster X-ray halos (Fabian 1994), ii) galactic cannibalism or the accretion of the existing galaxy population through dynamical friction and tidal stripping (Ostriker & Tremaine 1975; Richstone 1976; Ostriker & Hausman 1977) and iii) galaxy merging in the early history of the formation of the cluster as expected in hierarchical cosmological models (Merritt 1985; Tremaine 1990). The cooling flow theory implies the creation of lots of new stars but generally there is weak evidence for this population (McNamara & O'Connell 1989). The galactic cannibalism picture fails when worked out in detail since the dynamical friction timescales are generally too long and so the expected amount of accreted luminosity falls short by an order of magnitude for making up a BCG's luminosity (Merritt 1985; Lauer 1985; Tremaine 1990). The failure of this model implies that BCG's must have an earlier origin and that galaxy merging within the cluster during collapse in a cosmological hierarchy is a possible alternative. The strong tendency for BCG's to align with their cluster population (Sastry 1968; Carter et al. 1980; Binggeli 1982; West 1994) also implies an origin coinciding with cluster collapse.
Most of the work on the formation of giant ellipticals has been based on studies of merging groups of several disk galaxies (Barnes 1989; Weil & Hernquist 1996) or small virialized clusters of spherical galaxies (Funato, Makino & Ebisuzaki 1993; Bode et al. 1994; Garijo, Athanassoula & Garcia-Gomez 1997) . These simulations reveal the high efficiency of dynamical friction in driving galaxy merging and the general tendency to produce remnants resembling elliptical galaxies. However, they are phenomenological studies that are still considerably detached from the context of hierarchical collapse in which elliptical galaxies and BCG's probably form. In this paper, we explore galaxy merging in a detailed cosmological simulation of cluster collapse including a realistic distribution of disk galaxies embedded in dark halos and show that it produces a consistent and quantitative picture for the origin of BCG's.