See

<project-file type=“source”/> <content> #include “node.h” #include <simprocess.h> #include <iostream>

Link::Link(Node *neighbor, float contact_rate) : SimSchedule(SIM_INFINITY) {

Neighbor = neighbor;
ContactRate = contact_rate;

}

void Link::handler(float Time, SimProcess *process) {

if (Neighbor == NULL) return;
Node *From = dynamic_cast<Node*>(owner());
if (From != NULL) From->transmit(Time, Neighbor, process);
Neighbor->transmit(Time, From, process);
  updateEvent(Time);
  if (process != NULL && process->logger() != NULL)
	process->log(Time, owner(), this);

}

void Link::updateEvent(float Time) {

if (Neighbor == NULL) setEventTime(SIM_INFINITY);
Node *From = dynamic_cast<Node*>(owner());
if (From == NULL) setEventTime(SIM_INFINITY);
bool me_to_neighbor = From->infectious() && !Neighbor->infected();
bool neighbor_to_me = Neighbor->infectious() && !From->infected();
if (me_to_neighbor || neighbor_to_me)
    setEventTime(Time + expRandom(ContactRate));
else setEventTime(SIM_INFINITY);

} </content> <use name=“link.h”/>