Making sure to use previous infected nodes for the current iteration.