Mark Cavendish edged out a narrow stage one victory to move into the early race lead at the Tour of California.