Question: what is the relationship between galaxy distance and velocity?
Answer: Hubble's Law says that an object's velocity away from an observer is directly proportional to its distance from the observer. In other words, the farther away something is the faster it is moving away from us. The spectrum of a galaxy allows you to measure its redshift.