A closer look at Local Group
The Milky Way and Andromeda belong to a gravitationally associated group along with Triangulum and many smaller galaxies.
Motions inside such groups can depart substantially from the large-scale expansion pattern. Gravity in a cluster or group contributes to this peculiar velocity.
Andromeda’s light is blueshifted relative to the Milky Way. A local gravitational motion can dominate over cosmic expansion at this distance. For the surrounding ideas, see Dwarf galaxy.
OpenStax · Astronomy 2e · 28.3 The Distribution of Galaxies in Space · THE GALAXIES OF THE LOCAL GROUP · Local Sheet on Wikipedia
Want to learn more about Local Group? Local Group on Wikipedia.

