-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscripts.nls
223 lines (205 loc) · 3.52 KB
/
scripts.nls
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
;-----------------------------------------------------------------------------------
;
; Write your scripts in this file
;
; Please, read the Info Tab for instructions...
;
;-----------------------------------------------------------------------------------
; You can add a comment starting with ";"
; First Script
to script1
clear ; Clear everything
BA-PA 300 2 1 ; Create a Preferential Attatchment Network with 300 nodes
layout "spring" ; Draw it with a spring distribution
end
; Second script
; Foreach sample
to script2
print-csv ["p" "diameter"]
foreach (range 0 .01 .001)
[ [p] ->
clear
BA-PA 300 2 1
ER-RN 0 p
print-csv (list p diameter)
]
end
; Third script
; Spread Dynamics sample
to script3
clear
print-csv ["Healthy" "Infected" "Recovery"]
ER-RN 300 .01
layout "spring"
repeat 10
[ Spread 1 0.3 0.3 0 50
print-csv spread-summary
]
end
; Fourth script
; Small World network sample
to script4
clear
foreach (range 10 50 10)
[ [p] ->
clear
WS p 4 0
layout "circle"
]
end
; Fifth script
; Several repetitions for every value of the parameter sample
to script5
clear
print-csv ["p" "diameter"]
foreach (range 0 .01 .001)
[ [p] ->
repeat 10
[
clear
BA-PA 300 2 1
ER-RN 0 p
print-csv (list p diameter)
]
]
end
; Sixth script
; Same as previous but storing and compputing mean of the 10 experiments
; for every probability value. After that, prints all the means and
; draws the plot (p,dm)
to script6
clear
let ds []
let ys []
print-csv ["p" "mean-diameter"]
foreach (range 0 .01 .001)
[ [p] ->
repeat 10
[
clear
BA-PA 200 2 1
ER-RN 0 p
set ds store diameter ds
]
set ys store (mean ds) ys
print-csv (list p (mean ds))
set ds []
]
print ys
plotTable (range 0 .01 .001) ys
end
to script7
clear
BA-PA 300 2 1
layout "spring"
let cs []
repeat 100
[
remove-node "uniform"
compute-centralities
compute-components
set cs store (length components) cs
]
plotTable (range 100) cs
end
to script8
clear
BA-PA 300 2 1
layout "spring"
let cs []
repeat 100
[
remove-node "degree"
compute-centralities
compute-components
set cs store (length components) cs
]
plotTable (range 100) cs
end
to demoER
clear
foreach (range 0 .3 .01)
[ [p] ->
clear
no-display
ER-RN 40 p
layout "circle"
display
plots
wait .1
]
layout "spring"
end
to demoWS
clear
foreach (range 0 .3 .01)
[ [p] ->
clear
no-display
WS 40 4 p
layout "circle"
display
plots
wait .1
]
layout "spring"
end
to demoBA
clear
foreach (range 1 5 1)
[ p ->
clear
BA-PA 100 2 p
plots
layout "spring"
wait 1
]
end
to demoGeo
clear
foreach (range 1 10 1)
[ p ->
clear
Geom 200 p
compute-centralities
plots
wait 1
]
end
to demoGrid
clear
Grid 10 10 false
layout "spring"
let cl []
repeat 100
[ Rewire .01
compute-centralities
plots
set cl store Average-clustering cl
]
print cl
plotTable (range 0 100) cl
end
to demoSpread
clear
Grid 10 10 false
layout "spring"
spread 1 .1 .1 .01 1000
end
to demoSpread2
clear
BA-PA 300 2 1
ER-RN 0 .001
layout "spring"
spread 1 .1 .1 .01 1000
end
;------------- Connected components ---------------
to-report component-sizes
compute-components
report map count components
end
to demo-sc-components
clear
ER-RN 300 .01
print component-sizes
end