Gravar-mail: A generic model for selective adaptation in networks of heterogeneous populations