Using Monte Carlo simulations, we study the evolution of contigent cooperation and ethnocentrism in the one-move game. Interactions and reproduction among computational agents are simulated on undirected and directed Barabási- Albert (BA) networks. We first replicate the Hammond-Axelrod model of in-group favoritism on a square lattice and then generalize this model on undirected and directed BA networks for both asexual and sexual reproduction cases. Our simulations demonstrate that irrespective of the mode of reproduction, ethnocentric strategy becomes common even though cooperation is individually costly and mechanisms such as reciprocity or conformity are absent. Moreover, our results indicate that the spread of favoritism toward similar others highly depends on the network topology and the associated heterogeneity of the studied population.