Collisions between galaxies, geometry of expansion.

Hubble discovered that galaxies are moving away at each other at a rate, today physicists believe that this rate is increasing. I've read about galactic collisions, and that the Andromeda galaxy will eventually collide with the milkyway. If the galaxies are moving away from each other, then how is it that galaxies can collide? I can't visualize the geometry of this.

Expansion [at present] is only effective on very large scales. Gravity rules local systems. It is otherwise difficult to explain why galaxies and solar system have held together.

It is fallacious to juxtapose 'expansion' with 'gravity'. One is a force the other is due to momentum. Gravity operates at all scales, and the overall expansion of the Universe is dictated by Gravity.

Instead, the key point is about the scale on which the material in the universe is distributed smoothly. To get a feel for this have a look at some of the great pics and movies on http://www.mpa-garching.mpg.de/galform/millennium/" [Broken] They are from simulations of the Universe (rather than data) but the results match our Universe very well, and its much easier to make pretty pics from computer simulations than real observations (just ask Hollywood :) ).

What you can see, is that on large scales, the material in the Universe is smoothly distributed, so that the rate of expansion is pretty much the same everywhere. The expansion rate is determined by the average density of material in the Universe and its properties as dictated by Einsteins theory of General Relativity, but the point is if the density is uniform so is the expansion.

As you go to smaller scales you can see that the Universe becomes more and more lumpy. This means that talking about the average expansion rate starts to make less sense, because the local density might be quite different from the average. In the case of the Milky Way and Andromeda, the density in our local area is more than the average, sufficiently so such that we are falling towards each other.

Note that the structure in the Universe evolves over time. Early on things were very smooth everywhere, but gravity acts to amplify any small difference, such that dense areas get denser and underdense areas get less dense as times goes by. This process of gravitational growth of the lumpiness takes place even though on average the whole Universe is expanding.