-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathepedemiology.pde
62 lines (55 loc) · 1.32 KB
/
epedemiology.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
visualize the SIR model
TODO:
- make more accurate according to SIR model
- use "t1" and find better way to represent graph(clustering)
- consider extending this project or creating one with algos
from ml class
*/
void setup(){
size( 500,500 );
settings s = new settings();
frameRate(1);
g.generateSeeds( seeds );
g.buildErdosReyni( g, 0.4);
}
void draw(){
/* Hold down a key to see the enture visualization */
if(keyPressed == true) {
/* build graph visualization ( only points ) */
drawGraph dg = new drawGraph(g,ran);
/* start contagion */
if(days < t){
while( findI != 1 ){
/* find one of the infected */
if (g.nodeStage.get( i ) == "I" && g.isVisited( visited,i ) == 0 ){
current = i;
findI = 1;
}
i++;
}
/* infect neighbors */
for(Integer node: g.adjList[ current ] ){
if(g.nodeStage.get(node) == "R"){
continue;
}
if(g.nodeStage.get(node) == "I"){
continue;
}
if(g.getProbability( p ) ){
g.nodeStage.put( node, "I" );
}
}
g.nodeStage.put(current, "R");
visited[current] = 1;
//g.printGraph();
i = 0;
ran = 1;
findI = 0;
days++;
redraw();
}else {
noLoop();
}
}
}