Yahoo and China’s Alibaba Group have agreed to a $7.1 billion deal in which the Hangzhou-based internet behemoth buys back half of Yahoo’s 40% stake in the company.