## Description

Consider an undirected graph G=(V,E) representing a population. Nodes of the graph are individuals. The presence of an edge between two individuals indicates that they are in close contact with each other (e.g, sharing a home or a workplace).

Generate a graph on 100 nodes as follows: for each pair of nodes, toss a fair coin and put an edge between them if and only if you get a heads. This gives you a population graph. Every individual is in one of the following states: susceptible, infected, or recovered (aka removed). The possible transition for each individual is susceptible to infected to recovered.

โ Data Structures:

โ Sets S, I and R.

โ Binary heap with nodes having

โ Node id

โ TimeStamp

โ Event type: Infection/Recovery โ Initially all nodes are in S.

โ Choose a starting node arbitrarily and call it u.

โ Insert this infection event in the min-Queue Q, with timestamp 0. โ While(;;)

โ e<-DeleteMin(Q)

โ If e is a Recovery event,

โ R<- R U {e.nodeID}

โ I<- I{e.nodeID}

โ If e is an infection event,

โ I<- I U {e.nodeID}

โ S<- S{e.nodeID}

โ Forall susceptible neighbors u of e.nodeId

โ Generate an infectionTime as follows

โ Toss a fair coin five times

โ Let j be the first time a head comes (if a head doesnโt appear at all, u doesnโt get infected because of e.nodeid), continue to next neighbor โ Insert into Q:

โ Node id:u

โ TimeStamp: e.timeStamp+j

โ Event type: Infection

โ (If u did get infected) generate recovery event:

โ Generate a random number k uniformly between

e.timeStamp+j and e.timeStamp+j+5 โ Insert into Q:

โ Node id:u

โ TimeStamp: k

โ Event type: Recovery

1. Plot the number of susceptible, infected and recovered individuals, against i.

2. Compare the instant at which a node gets infected with itโs shortest distance from the start node s.

## Reviews

There are no reviews yet.