Functiont that simulates an epidemic in a network of contacts.