Protection against Contagion in Complex Networks