Network Formation Under Heterogeneous Costs: The Multiple Group Model