 Graham was born in New York City.He entered the Navy in October 1841, at the age of 17 and served as a midshipman in the Gulf of Mexico during the Mexican–American War, resigning his commission in May 1848.Later he studied engineering and was for several years after 1857 constructing engineer of the Brooklyn Navy Yard.