The adaptive value of density-dependent habitat specialization and social network centrality