-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtests.txt
1831 lines (1598 loc) · 67.8 KB
/
tests.txt
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Ideally, for each primitive, we should think about cases such as:
# - Parameter values: negative, 0, 1, possible maximums (e.g. 1E38)
# - same input twice (e.g. distance to self)
# Different network configurations:
# - empty networks
# - partially disconnected networks
# - completely disconnect networks
# - Directed vs. undirected networks
# - using undirected primitives with directed networks
# - using directed versions of primitives on undirected networks
# For primitives using weights:
# - non numeric weights
# - negative weights
# Note:
# undirected-edges/edge and directed-edges/edge refer to undirected and directed breeds, respectively.
# Note that is-directed-link? / is-undirected-link? do not check breed identity,
# but rather whether the particular links are directed or undirected, regardless of
# breed membership
### set-context tests
clear-all-clears-context
extensions [nw]
O> crt 2 [ create-links-with other turtles ]
O> nw:set-context (turtle-set turtles) (link-set links)
(word map sort nw:get-context) => "[[(turtle 0) (turtle 1)] [(link 0 1)]]"
O> clear-all
(map sort nw:get-context) => [[] []]
O> crt 2 [ create-links-with other turtles ]
(word map sort nw:get-context) => "[[(turtle 0) (turtle 1)] [(link 0 1)]]"
distance-after-changes
extensions [nw]
O> crt 2
O> ask turtle 0 [ create-link-with turtle 1 ]
[ nw:distance-to turtle 1 ] of turtle 0 => 1
O> ask links [ die ]
[ nw:distance-to turtle 1 ] of turtle 0 => false
O> crt 1
O> ask turtle 0 [ create-link-with turtle 2 ]
O> ask turtle 2 [ create-link-with turtle 1 ]
[ nw:distance-to turtle 1 ] of turtle 0 => 2
closeness-after-births
extensions [ nw ]
O> crt 1
[ nw:closeness-centrality ] of turtle 0 => 0
O> crt 2
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 1 0.67]
closeness-after-deaths
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 1 0.67]
O> ask turtle 1 [ die ]
O> ask turtle 0 [ create-link-with turtle 2 ]
[ nw:closeness-centrality ] of turtles => [1 1]
default-context-with-undir-links-betweenness
extensions [nw]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 2 [ create-undirected-edge-with one-of other turtles ]
[ nw:betweenness-centrality ] of turtles => [0 0]
undir-context-with-undir-links-betweenness
extensions [nw]
undirected-link-breed [undirected-edges undirected-edge]
O> nw:set-context turtles undirected-edges
O> crt 2 [ create-undirected-edge-with one-of other turtles ]
[ nw:betweenness-centrality ] of turtles => [0 0]
default-context-with-undir-links-closeness
extensions [nw]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 2 [ create-undirected-edge-with one-of other turtles ]
[ nw:closeness-centrality ] of turtles => [1 1]
default-context-with-undir-links-distance
extensions [nw]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 2 [ create-undirected-edge-with one-of other turtles ]
[ nw:distance-to turtle 1 ] of turtle 0 => 1
after-clear-turtles
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
O> clear-turtles
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
after-clear-turtles-agentset
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
O> nw:set-context (turtle-set turtles) links
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
O> clear-turtles
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => false
after-world-resize_2D
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
O> resize-world -1 1 -1 1
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
O> resize-world -2 2 -2 2
O> resize-world -1 1 -1 1
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
after-world-resize_3D
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
O> resize-world -1 1 -1 1 -1 1
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to one-of other turtles ] of one-of turtles => 1
## set-context with non-breed agentsets
path-through-different-breeds
extensions [ nw ]
breed [mice mouse]
breed [frogs frog]
undirected-link-breed [undirected-edges undirected-edge]
undirected-edges-own [weight]
O> create-frogs 1
O> create-mice 2 [ create-undirected-edges-with frogs ]
O> ask undirected-edges [ set weight 2 ]
O> nw:set-context (turtle-set mice frogs) (link-set undirected-edges)
[ nw:distance-to mouse 2 ] of mouse 1 => 2
[ nw:weighted-distance-to mouse 2 weight ] of mouse 1 => 4
O> ask frogs [ die ]
[ nw:distance-to mouse 2 ] of mouse 1 => false
[ nw:weighted-distance-to mouse 2 weight ] of mouse 1 => false
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 3 ]
# new agents not added to non-breed context:
[ nw:distance-to mouse 4 ] of mouse 5 => false
after-world-resize-non-breed_2D
extensions [ nw ]
breed [mice mouse]
breed [frogs frog]
undirected-link-breed [undirected-edges undirected-edge]
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 0 ]
O> nw:set-context (turtle-set mice frogs) (link-set undirected-edges)
[ nw:distance-to mouse 2 ] of mouse 1 => 2
O> resize-world -1 1 -1 1
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 3 ]
# new agents should not be added to context:
[ nw:distance-to mouse 4 ] of mouse 5 => false
after-world-resize-non-breed_3D
extensions [ nw ]
breed [mice mouse]
breed [frogs frog]
undirected-link-breed [undirected-edges undirected-edge]
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 0 ]
O> nw:set-context (turtle-set mice frogs) (link-set undirected-edges)
[ nw:distance-to mouse 2 ] of mouse 1 => 2
O> resize-world -1 1 -1 1 -1 1
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 3 ]
# new agents should not be added to context:
[ nw:distance-to mouse 4 ] of mouse 5 => false
closeness-after-births-non-breed
extensions [ nw ]
breed [mice mouse]
breed [frogs frog]
undirected-link-breed [undirected-edges undirected-edge]
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 0 ]
O> nw:set-context (turtle-set mice frogs) (link-set undirected-edges)
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [1 0.67 0.67]
O> crt 1
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => ERROR Extension exception: turtle 3 is not a member of the current graph context.
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles with [ who < 3 ] => [1 0.67 0.67]
closeness-after-deaths-non-breed
extensions [ nw ]
breed [mice mouse]
breed [frogs frog]
undirected-link-breed [undirected-edges undirected-edge]
O> create-frogs 1
O> create-mice 2 [ create-undirected-edge-with frog 0 ]
O> nw:set-context (turtle-set mice frogs) (link-set undirected-edges)
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [1 0.67 0.67]
O> ask frogs [ die ]
# create new link that should not be part of context:
O> ask mouse 1 [ create-link-with mouse 2 ]
[ nw:closeness-centrality ] of turtles => [0 0]
### with-context tests
with-context-actually-runs-body
extensions [ nw ]
globals [ glob1 ]
O> nw:with-context turtles links [ set glob1 5 ]
glob1 => 5
with-context-changes-context-temporarily
extensions [ nw ]
globals [ glob1 glob2 ]
O> create-turtles 2 [ create-links-with other turtles ]
O> set glob1 turtle-set turtles
O> create-turtles 1 [ create-links-with other turtles ]
[ count nw:turtles-in-radius 1 ] of turtle 0 => 3
O> nw:with-context glob1 links [ set glob2 [ nw:turtles-in-radius 1 ] of turtle 0 ]
count glob2 => 2
[ member? turtle 0 nw:turtles-in-radius 1 ] of turtle 0 => true
[ member? turtle 1 nw:turtles-in-radius 1 ] of turtle 0 => true
[ member? turtle 2 nw:turtles-in-radius 1 ] of turtle 0 => true
[ count nw:turtles-in-radius 1 ] of turtle 0 => 3
with-context-can-be-nested
extensions [ nw ]
globals [ glob1 glob2 ]
O> crt 3
O> ask turtles [ create-links-with other turtles ]
O> nw:with-context (turtle-set turtle 0 turtle 1) links [ nw:with-context (turtle-set turtle 0) links [ set glob1 [ nw:turtles-in-radius 1 ] of turtle 0 ] set glob2 [ nw:turtles-in-radius 1 ] of turtle 0 ]
count glob1 => 1
count glob2 => 2
count [ nw:turtles-in-radius 1 ] of turtle 0 => 3
with-context-changes-get-context
extensions [ nw ]
globals [ glob1 glob2 glob3 ]
O> crt 3
O> ask turtles [ create-links-with other turtles ]
O> set glob1 (turtle-set turtle 0 turtle 1)
O> set glob2 (link-set link 0 1)
O> nw:with-context glob1 glob2 [ set glob3 nw:get-context ]
glob3 = (list glob1 glob2) => true
nw:get-context = (list turtles links) => true
### turtles-in-radius
turtles-in-radius-negative-radius
extensions [nw]
O> crt 1
[nw:turtles-in-radius -1] of turtle 0 => ERROR Extension exception: radius cannot be negative
turtles-in-radius-zero-radius
extensions [nw]
O> crt 5
remove-duplicates [count nw:turtles-in-radius 0] of turtles => [1]
turtles-in-radius-two-circles
extensions [nw]
O> crt 8 [ create-link-with turtle ((who + 1) mod 8) ]
O> crt 8 [ create-link-with turtle ((who - 8 + 1) mod 8 + 8) ]
remove-duplicates [count nw:turtles-in-radius 0] of turtles => [1]
remove-duplicates [count nw:turtles-in-radius 1 ] of turtles => [3]
remove-duplicates [count nw:turtles-in-radius 2 ] of turtles => [5]
remove-duplicates [count nw:turtles-in-radius 3 ] of turtles => [7]
remove-duplicates [count nw:turtles-in-radius 4 ] of turtles => [8]
remove-duplicates [count nw:turtles-in-radius 5 ] of turtles => [8]
remove-duplicates [count nw:turtles-in-radius 1E38 ] of turtles => [8]
in-link-radius-source-set-filtering
extensions [nw]
breed [mice mouse]
O> crt 8 [ create-links-with other turtles ]
O> ask turtles with [who mod 2 = 0] [ set breed mice ]
O> nw:set-context mice links
sort [who] of [nw:turtles-in-radius 10] of turtle 0 => [0 2 4 6]
mixed-turtles-in-radius
extensions [nw]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> cro 13
O> ask turtle 0 [ create-undirected-edge-with turtle 1 ]
O> ask turtle 0 [ create-directed-edge-to turtle 2 ]
O> ask turtle 0 [ create-directed-edge-from turtle 3 ]
O> ask turtle 1 [ create-undirected-edge-with turtle 4 ]
O> ask turtle 1 [ create-directed-edge-to turtle 5 ]
O> ask turtle 1 [ create-directed-edge-from turtle 6 ]
O> ask turtle 2 [ create-undirected-edge-with turtle 7 ]
O> ask turtle 2 [ create-directed-edge-to turtle 8 ]
O> ask turtle 2 [ create-directed-edge-from turtle 9 ]
O> ask turtle 3 [ create-undirected-edge-with turtle 10 ]
O> ask turtle 3 [ create-directed-edge-to turtle 11 ]
O> ask turtle 3 [ create-directed-edge-from turtle 12 ]
sort [who] of [nw:turtles-in-radius 1] of turtle 0 => [0 1 2]
sort [who] of [nw:turtles-in-reverse-radius 1] of turtle 0 => [0 1 3]
sort [who] of [nw:turtles-in-radius 2] of turtle 0 => [0 1 2 4 5 7 8]
sort [who] of [nw:turtles-in-reverse-radius 2] of turtle 0 => [0 1 3 4 6 10 12]
O> nw:set-context turtles undirected-edges
sort [who] of [nw:turtles-in-radius 1] of turtle 0 => [0 1]
sort [who] of [nw:turtles-in-radius 2] of turtle 0 => [0 1 4]
O> nw:set-context turtles directed-edges
sort [who] of [nw:turtles-in-radius 1] of turtle 0 => [0 2]
sort [who] of [nw:turtles-in-radius 2] of turtle 0 => [0 2 8]
sort [who] of [nw:turtles-in-reverse-radius 1] of turtle 0 => [0 3]
sort [who] of [nw:turtles-in-reverse-radius 2] of turtle 0 => [0 3 12]
### turtles-in-out-radius, turtles-in-in-radius
turtles-in-out-radius
extensions [nw]
O> crt 2
O> ask turtle 0 [ create-link-to turtle 1 ]
sort [ who ] of [ nw:turtles-in-radius 1 ] of turtle 0 => [0 1]
sort [ who ] of [ nw:turtles-in-radius 1 ] of turtle 1 => [1]
turtles-in-in-radius
extensions [nw]
O> crt 2
O> ask turtle 0 [ create-link-to turtle 1 ]
sort [who] of [ nw:turtles-in-reverse-radius 1 ] of turtle 0 => [0]
sort [who] of [ nw:turtles-in-reverse-radius 1 ] of turtle 1 => [0 1]
### distance-to
distance-to-self
extensions [nw]
O> crt 1
[ nw:distance-to turtle 0 ] of turtle 0 => 0
[ nw:distance-to turtle 0 ] of turtle 0 => 0
distance-two-turtles-no-links
extensions [nw]
O> crt 2
[ nw:distance-to turtle 0 ] of turtle 1 => false
[ nw:distance-to turtle 1 ] of turtle 0 => false
[ nw:distance-to turtle 0 ] of turtle 1 => false
[ nw:distance-to turtle 1 ] of turtle 0 => false
distance-one-undirected-link
extensions [nw]
O> crt 2 [ create-links-with other turtles ]
[ nw:distance-to turtle 0 ] of turtle 1 => 1
[ nw:distance-to turtle 1 ] of turtle 0 => 1
distance-chain-caching-interference
extensions [nw]
O> crt 4
O> ask turtles [ create-links-with turtles with [ who = [ who + 1 ] of myself ] ]
[ nw:distance-to turtle 2 ] of turtle 0 => 2
[ nw:distance-to turtle 2 ] of turtle 0 => 2
[ nw:distance-to turtle 1 ] of turtle 0 => 1
[ nw:distance-to turtle 3 ] of turtle 0 => 3
distance-one-directed-link
extensions [nw]
O> crt 2
O> ask turtle 0 [ create-link-to turtle 1 ]
[ nw:distance-to turtle 0 ] of turtle 1 => false
[ nw:distance-to turtle 1 ] of turtle 0 => 1
distance-always-one-in-fully-connected-network
extensions [ nw ]
to-report distances report [ nw:distance-to myself ] of link-neighbors end
O> crt 10 [ create-links-with other turtles ]
remove-duplicates reduce sentence [distances] of turtles => [1]
distance-along-chain
extensions [ nw ]
O> crt 5 [ if who < 4 [ create-link-with turtle (who + 1) ] ]
sort [ nw:distance-to turtle 0 ] of turtles => [0 1 2 3 4]
sort [ nw:distance-to turtle 4 ] of turtles => [0 1 2 3 4]
sort remove-duplicates [ nw:distance-to turtle 2 ] of turtles => [0 1 2]
distance-around-circle
extensions [ nw ]
O> crt 8 [ create-link-with turtle ((who + 1) mod 8) ]
sort [ nw:distance-to turtle 0 ] of turtles => [0 1 1 2 2 3 3 4]
distance-around-two-circles
extensions [ nw ]
O> crt 8 [ create-link-with turtle ((who + 1) mod 8) ]
O> crt 8 [ create-link-with turtle ((who - 8 + 1) mod 8 + 8) ]
sort [ nw:distance-to turtle 0 ] of turtles with [who < 8] => [0 1 1 2 2 3 3 4]
sort [ nw:distance-to turtle 8 ] of turtles with [who >= 8] => [0 1 1 2 2 3 3 4]
remove-duplicates [ nw:distance-to turtle 8 ] of turtles with [who < 8] => [false]
remove-duplicates [ nw:distance-to turtle 0 ] of turtles with [who >= 8] => [false]
### path-to
path-to-self
extensions [ nw ]
O> crt 1
[ nw:path-to turtle 0 ] of turtle 0 => []
path-to-no-path
extensions [ nw ]
O> crt 2
[ nw:path-to turtle 1 ] of turtle 0 => false
[ nw:path-to turtle 0 ] of turtle 1 => false
path-to-undirected-pair
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
(word [ nw:path-to turtle 1 ] of turtle 0) => "[(link 0 1)]"
(word [ nw:path-to turtle 0 ] of turtle 1) => "[(link 0 1)]"
path-to-a-b-c-undirected
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
(word [ nw:path-to turtle 2 ] of turtle 0) => "[(link 0 1) (link 1 2)]"
(word [ nw:path-to turtle 0 ] of turtle 2) => "[(link 1 2) (link 0 1)]"
path-to-a-b-c-directed
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-to turtle 1 ]
O> ask turtle 1 [ create-link-to turtle 2 ]
(word [ nw:path-to turtle 2 ] of turtle 0) => "[(link 0 1) (link 1 2)]"
(word [ nw:path-to turtle 0 ] of turtle 2) => "false"
path-to-fully-connected
extensions [ nw ]
O> crt 6 [ create-links-with other turtles ]
(word sort map [ [p] -> (word p)] [ nw:path-to turtle 0 ] of turtles) => "[[(link 0 1)] [(link 0 2)] [(link 0 3)] [(link 0 4)] [(link 0 5)] []]"
path-to-on-a-circle
extensions [ nw ]
O> crt 6 [ create-link-with turtle ((who + 1) mod 6) ]
sort [ length nw:path-to turtle 0 ] of turtles => [0 1 1 2 2 3]
path-to-random-equal-paths
extensions [ nw ]
O> cro 4 [ create-link-with turtle ((who + 1) mod 4) ]
length remove-duplicates n-values 100 [ [ nw:path-to turtle 2 ] of turtle 0 ] => 2
path-to-random-equal-paths-parallel-links
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> cro 3
O> ask turtle 0 [ create-undirected-edge-with turtle 1 ]
O> ask turtle 1 [ create-undirected-edge-with turtle 2 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
length remove-duplicates n-values 100 [ [ nw:path-to turtle 2 ] of turtle 0 ] => 2
path-to-mixed-directed-undirected
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 4
O> ask turtle 0 [ create-undirected-edge-with turtle 1 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
O> ask turtle 3 [ create-directed-edge-to turtle 1 ]
(word [ nw:path-to turtle 2 ] of turtle 0) => "[(undirected-edge 0 1) (directed-edge 1 2)]"
(word [ nw:turtles-on-path-to turtle 2 ] of turtle 0) => "[(turtle 0) (turtle 1) (turtle 2)]"
(word [ nw:path-to turtle 3 ] of turtle 0) => "false"
(word [ nw:turtles-on-path-to turtle 3 ] of turtle 0) => "false"
(word [ nw:path-to turtle 0 ] of turtle 3) => "[(directed-edge 3 1) (undirected-edge 0 1)]"
(word [ nw:turtles-on-path-to turtle 0 ] of turtle 3) => "[(turtle 3) (turtle 1) (turtle 0)]"
### turtles-on-path-to
turtles-on-path-to-self
extensions [ nw ]
O> crt 1
map [ [t] -> [who] of t ] [ nw:turtles-on-path-to turtle 0 ] of turtle 0 => [0]
turtles-on-path-to-no-path
extensions [ nw ]
O> crt 2
[ nw:turtles-on-path-to turtle 1 ] of turtle 0 => false
[ nw:turtles-on-path-to turtle 0 ] of turtle 1 => false
turtles-on-path-to-undirected-pair
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
map [[t] -> [who] of t] [ nw:turtles-on-path-to turtle 1 ] of turtle 0 => [0 1]
map [[t] -> [who] of t] [ nw:turtles-on-path-to turtle 0 ] of turtle 1 => [1 0]
turtles-on-path-to-directed-pair
extensions [ nw ]
O> crt 2
O> ask turtle 0 [ create-link-to turtle 1 ]
map [ [t] -> [who] of t ] [ nw:turtles-on-path-to turtle 1 ] of turtle 0 => [0 1]
[ nw:turtles-on-path-to turtle 0 ] of turtle 1 => false
turtles-on-path-to-fully-connected
extensions [ nw ]
O> crt 6 [ create-links-with other turtles ]
sort [length nw:turtles-on-path-to turtle 0 ] of turtles => [1 2 2 2 2 2]
turtles-on-path-to-on-a-circle
extensions [ nw ]
O> crt 6 [ create-link-with turtle ((who + 1) mod 6) ]
sort [length nw:turtles-on-path-to turtle 0 ] of turtles => [1 2 2 3 3 4]
turtles-on-path-to-random-equal-paths
extensions [ nw ]
O> cro 4 [ create-link-with turtle ((who + 1) mod 4) ]
length remove-duplicates n-values 100 [ [ nw:turtles-on-path-to turtle 2 ] of turtle 0 ] => 2
### mean-path-length
## undirected links
mean-path-length-empty
extensions [ nw ]
nw:mean-path-length => false
mean-path-length-one-turtle
extensions [ nw ]
O> crt 1
nw:mean-path-length => false
mean-path-length-two-unconnected-turtles
extensions [ nw ]
O> crt 2
nw:mean-path-length => false
mean-path-length-two-connected-turtles
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
nw:mean-path-length => 1
mean-path-length-two-connected-and-one-unconnected-turtles
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
O> crt 1
nw:mean-path-length => false
mean-path-length-fully-connected
extensions [ nw ]
O> crt 10 [ create-links-with other turtles ]
nw:mean-path-length => 1
mean-path-length-on-a-pentagon
extensions [ nw ]
O> crt 5 [ create-link-with turtle ((who + 1) mod 5) ]
nw:mean-path-length => 1.5
mean-path-length-connected-pair-of-turtles-on-a-pentagon
extensions [ nw ]
breed [mice mouse]
O> nw:set-context mice links
O> crt 5 [ create-link-with turtle ((who + 1) mod 5) ]
O> ask (turtle-set turtle 0 turtle 1) [ set breed mice ]
nw:mean-path-length => 1
mean-path-length-disconnected-pair-of-turtles-on-a-pentagon
extensions [ nw ]
breed [mice mouse]
O> nw:set-context mice links
O> crt 5 [ create-link-with turtle ((who + 1) mod 5) ]
O> ask (turtle-set turtle 0 turtle 2) [ set breed mice ]
nw:mean-path-length => false
## directed links
mean-path-length-directed-two-half-connected-turtles
extensions [ nw ]
O> crt 2
O> ask turtle 0 [ create-links-to other turtles ]
nw:mean-path-length => false
mean-path-length-directed-two-connected-turtles
extensions [ nw ]
O> crt 2 [ create-links-to other turtles ]
nw:mean-path-length => 1
## centrality primitives
### closeness-centrality
closeness-centrality-empty
extensions [ nw ]
[ nw:closeness-centrality ] of turtles => []
closeness-centrality-single-isolate
extensions [ nw ]
O> crt 1
[ nw:closeness-centrality ] of turtle 0 => 0
closeness-centrality-directed-pair
extensions [ nw ]
O> crt 2
O> ask turtle 0 [ create-link-to turtle 1 ]
map [ [t] -> [ precision nw:closeness-centrality 3 ] of t ] sort turtles => [1 0]
closeness-centrality-simple-mixed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 3
O> ask turtle 0 [ create-undirected-edge-with turtle 1 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
map [ [t] -> [ precision nw:closeness-centrality 3 ] of t ] sort turtles => [0.667 1 0]
closeness-centrality-simple-undirected
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 1 0.67]
closeness-centrality-simple-directed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
O> crt 3
O> ask turtle 0 [ create-directed-edge-to turtle 1 ]
O> ask turtle 1 [ create-directed-edge-to turtle 0 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
O> ask turtle 2 [ create-directed-edge-to turtle 1 ]
O> nw:set-context turtles directed-edges
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 1 0.67]
closeness-centrality-bigger-directed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
O> crt 6
O> ask turtle 0 [ create-directed-edge-to turtle 1 ]
O> ask turtle 1 [ create-directed-edge-to turtle 5 ]
O> ask turtle 2 [ create-directed-edge-to turtle 1 ]
O> ask turtle 2 [ create-directed-edge-to turtle 3 ]
O> ask turtle 2 [ create-directed-edge-to turtle 4 ]
O> ask turtle 4 [ create-directed-edge-to turtle 3 ]
O> ask turtle 5 [ create-directed-edge-to turtle 0 ]
O> ask turtle 5 [ create-directed-edge-to turtle 4 ]
O> nw:set-context turtles directed-edges
map [ [t] -> [ precision nw:closeness-centrality 3 ] of t ] sort turtles => [0.4 0.5 0.625 0 1 0.667]
closeness-centrality-disconnected-pentagon-triangle
extensions [ nw ]
O> crt 5 [ create-link-with turtle ((who + 1) mod 5) ]
O> crt 3 [ create-link-with turtle (((who - 4) mod 3) + 5)]
O> ask turtle 5 [ create-link-with turtle 6 ]
O> ask turtle 6 [ create-link-with turtle 7 ]
O> ask turtle 7 [ create-link-with turtle 5 ]
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 0.67 0.67 0.67 0.67 1 1 1]
weighted-closeness-centrality-pair-undirected
extensions [ nw ]
O> crt 2
O> ask turtle 0 [ create-link-with turtle 1 [ set thickness 2 ] ]
map [ [t] -> [ precision nw:weighted-closeness-centrality thickness 2 ] of t ] sort turtles => [0.5 0.5]
weighted-closeness-centrality-simple-undirected
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 [ set thickness 2 ] ]
O> ask turtle 1 [ create-link-with turtle 2 [ set thickness 1 ] ]
map [ [t] -> [ precision nw:weighted-closeness-centrality thickness 2 ] of t ] sort turtles => [0.4 0.67 0.5]
weighted-closeness-centrality-simple-directed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
O> crt 3
O> ask turtle 0 [ create-directed-edge-to turtle 1 [ set thickness 1 ] ]
O> ask turtle 1 [ create-directed-edge-to turtle 0 [ set thickness 2 ] ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 [ set thickness 2 ] ]
O> ask turtle 2 [ create-directed-edge-to turtle 1 [ set thickness 1 ] ]
O> nw:set-context turtles directed-edges
map [ [t] -> [ precision nw:weighted-closeness-centrality thickness 2 ] of t ] sort turtles => [0.5 0.5 0.5]
weighted-closeness-centrality-changes
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 [ set thickness 2 ] ]
O> ask turtle 1 [ create-link-with turtle 2 [ set thickness 1 ] ]
map [ [t] -> [ precision nw:weighted-closeness-centrality thickness 2 ] of t ] sort turtles => [0.4 0.67 0.5]
O> ask turtle 0 [ create-link-with turtle 1 [ set thickness 1 ] ]
map [ [t] -> [ precision nw:closeness-centrality 2 ] of t ] sort turtles => [0.67 1 0.67]
### betweenness-centrality
betweenness-centrality-empty
extensions [ nw ]
[ nw:betweenness-centrality ] of turtles => []
betweenness-centrality-single-isolate
extensions [ nw ]
O> crt 1
[ nw:betweenness-centrality ] of turtle 0 => 0
betweenness-centrality-simple-undirected
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 1 0]
betweenness-centrality-simple-undirected-changes
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 1 0]
O> ask turtle 2 [ create-link-with turtle 0 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 0 0]
betweenness-centrality-central-node-undirected
extensions [ nw ]
O> crt 11
O> ask turtle 0 [ create-links-with other turtles ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [45 0 0 0 0 0 0 0 0 0 0]
betweenness-centrality-disconnected-undirected
extensions [ nw ]
O> crt 6
O> ask turtle 0 [ create-link-with turtle 1 ]
O> ask turtle 1 [ create-link-with turtle 2 ]
O> ask turtle 3 [ create-link-with turtle 4 ]
O> ask turtle 4 [ create-link-with turtle 5 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 1 0 0 1 0]
betweenness-centrality-directed-triangle
extensions [ nw ]
O> crt 3 [ create-link-to turtle ((who + 1) mod 3) ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [1 1 1]
betweenness-centrality-disconnected-directed-triangles
extensions [ nw ]
O> crt 3 [ create-link-to turtle ((who + 1) mod 3) ]
O> crt 3 [ create-link-to turtle (((who - 2) mod 3) + 3) ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [1 1 1 1 1 1]
betweenness-centrality-connected-directed-triangles
extensions [ nw ]
O> crt 3 [ create-link-to turtle ((who + 1) mod 3) ]
O> crt 3 [ create-link-to turtle (((who - 2) mod 3) + 3) ]
O> ask turtle 0 [ create-link-to turtle 3 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [7 1 4 7 4 1]
betweenness-centrality-bigger-connected-directed-graph
extensions [ nw ]
O> crt 6
O> ask turtle 0 [ create-link-to turtle 4 ]
O> ask turtle 1 [ create-link-to turtle 4 ]
O> ask turtle 2 [ create-link-to turtle 0 ]
O> ask turtle 2 [ create-link-to turtle 4 ]
O> ask turtle 2 [ create-link-to turtle 1 ]
O> ask turtle 4 [ create-link-to turtle 3 ]
O> ask turtle 4 [ create-link-to turtle 0 ]
O> ask turtle 4 [ create-link-to turtle 5 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 0 0 0 7 0]
betweennes-centrality-directed-line
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
O> crt 3
O> ask turtle 0 [ create-directed-edge-to turtle 1 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [0 1 0]
betweenness-centrality-center-node
extensions [ nw ]
O> crt 5
O> ask turtle 0 [ create-links-with other turtles ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [6 0 0 0 0]
betweenness-centrality-mixed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 5
O> ask turtle 0 [ create-undirected-edge-with turtle 1 ]
O> ask turtle 0 [ create-directed-edge-to turtle 2 ]
O> ask turtle 0 [ create-directed-edge-from turtle 3 ]
O> ask turtle 0 [ create-directed-edge-from turtle 4 ]
map [ [t] -> [ nw:betweenness-centrality ] of t ] sort turtles => [5 0 0 0 0]
### eigenvector-centrality
eigenvector-centrality-empty
extensions [ nw ]
[ nw:eigenvector-centrality ] of turtles => []
eigenvector-centrality-single-isolate
extensions [ nw ]
O> crt 1
[ nw:eigenvector-centrality ] of turtle 0 => 1
eigenvector-centrality-disconnected
extensions [ nw ]
O> crt 4
map [ [t] -> [ nw:eigenvector-centrality ] of t ] sort turtles => [1 1 1 1]
O> ask turtle 0 [ create-link-with turtle 1 ]
map [ [t] -> [ nw:eigenvector-centrality ] of t ] sort turtles => [1 1 1 1]
eigenvector-centrality-pair
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
map [ [t] -> [ nw:eigenvector-centrality ] of t ] sort turtles => [1 1]
eigenvector-directed-centrality-pair
extensions [ nw ]
O> crt 2
O> ask turtle 0 [ create-links-to other turtles ]
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0 1]
# Power iteration fails in this case. Gephi computes it successfully, but I'm using the same technique...
# Power iteration actually fails for any odd length line...
eigenvector-centrality-3-line
extensions [ nw ]
O> crt 3
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
O> nw:set-context turtles links
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0.707 1 0.707]
eigenvector-centrality-4-line
extensions [ nw ]
O> crt 4
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
O> nw:set-context turtles links
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0.618 1 1 0.618]
eigenvector-centrality-6-line
extensions [ nw ]
O> crt 6
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
O> nw:set-context turtles links
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0.445 0.802 1 1 0.802 0.445]
# matches gephi when you run gephi for 10000 iterations
eigenvector-centrality-assymetric
extensions [ nw ]
O> crt 4
O> ask turtle 0 [ create-links-with other turtles ]
O> ask turtle 1 [ create-link-with turtle 2 ]
map [ [t] -> [ precision nw:eigenvector-centrality 3] of t ] sort turtles => [1 0.855 0.855 0.461]
eigenvector-centrality-changes
extensions [ nw ]
O> crt 4
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
O> nw:set-context turtles links
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0.618 1 1 0.618]
O> crt 2
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0.445 0.802 1 1 0.802 0.445]
# This is the one test where we disagree with Gephi. Gephi refuses to compute centrality on mixed networks.
eigenvector-centrality-mixed
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 3
O> ask turtle 0 [ create-directed-edge-to turtle 1 ]
O> ask turtle 1 [ create-undirected-edge-with turtle 2 ]
map [ [t] -> [ precision nw:eigenvector-centrality 3 ] of t ] sort turtles => [0 1 1]
page-rank-3-line
extensions [ nw ]
O> crt 3
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
map [ [t] -> [ precision nw:page-rank 3 ] of t ] sort turtles => [0.257 0.486 0.257]
page-rank-disconnected
extensions [ nw ]
O> crt 4
map [ [t] -> [ precision nw:page-rank 3 ] of t ] sort turtles => [0.25 0.25 0.25 0.25]
page-rank-changes
extensions [ nw ]
O> crt 3
O> ask turtles with [ who < count turtles - 1 ] [ create-link-with turtle (who + 1) ]
map [ [t] -> [ precision nw:page-rank 3 ] of t ] sort turtles => [0.257 0.486 0.257]
O> ask turtle 2 [ die ]
map [ [t] -> [ precision nw:page-rank 3 ] of t ] sort turtles => [0.5 0.5]
### clustering coefficient
isolated-clustering-coefficient
extensions [ nw ]
O> crt 1
[ nw:clustering-coefficient ] of turtle 0 => 0
pair-clustering-coefficient
extensions [ nw ]
O> crt 2 [ create-links-with other turtles ]
[ nw:clustering-coefficient ] of turtles => [0 0]
triangle-clustering-coefficient
extensions [ nw ]
O> crt 3 [ create-links-with other turtles ]
[ nw:clustering-coefficient ] of turtles => [1 1 1]
square-with-diag-clustering-coefficient
extensions [ nw ]
O> crt 4
O> ask turtles [ create-link-with turtle ((who + 1) mod count turtles) ]
O> ask turtle 0 [ create-link-with turtle 2 ]
map [ [t] -> [ precision nw:clustering-coefficient 3 ] of t ] sort turtles => [0.667 1 0.667 1]
directed-triangle-clustering-coefficient
extensions [ nw ]
O> crt 3
O> ask turtle 0 [ create-link-to turtle 1 create-link-to turtle 2 ]
O> ask turtle 1 [ create-link-to turtle 0 create-link-to turtle 2 ]
map [ [t] -> [ precision nw:clustering-coefficient 3 ] of t ] sort turtles => [0.5 0.5 0]
mixed-triangle-clustering-coefficient
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 3
O> ask turtle 0 [ create-undirected-edge-with turtle 1 create-directed-edge-to turtle 2 ]
O> ask turtle 1 [ create-directed-edge-to turtle 2 ]
map [ [t] -> [ precision nw:clustering-coefficient 3 ] of t ] sort turtles => [0.5 0.5 0]
## Modularity
undirected-separate-components
extensions [ nw ]
O> crt 100 [ set color blue ]
O> crt 100 [ set color red ]
O> ask turtles [ create-links-with other turtles with [ color = [ color ] of myself ] ]
nw:modularity nw:weak-component-clusters => 0.5
directed-separate-components
extensions [ nw ]
O> crt 100 [ set color blue ]
O> crt 100 [ set color red ]
O> ask turtles [ create-links-to other turtles with [ color = [ color ] of myself ] ]
nw:modularity nw:weak-component-clusters => 0.5
## Louvain Communities
louvain-communities
extensions [ nw ]
O> crt 9
O> random-seed 0
O> foreach [[0 1] [1 2] [2 3] [3 0] [0 4] [4 5] [5 6] [6 7] [7 4] [1 7] [8 0] [8 1] [8 2] [8 3]] [ [ends] -> ask turtle first ends [ create-link-with turtle last ends ] ]
sort map count nw:louvain-communities => [4 5]
louvain-communities-multi-components
extensions [ nw ]
O> crt 9
O> random-seed 1
O> foreach [[0 1] [1 2] [2 3] [3 0] [0 4] [4 5] [5 6] [6 7] [7 4] [1 7] [8 0] [8 1] [8 2] [8 3]] [ [ends] -> ask turtle first ends [ create-link-with turtle last ends ] ]
O> crt 1
sort map count nw:louvain-communities => [1 4 5]
louvain-communities-mixed
extensions [ nw ]
undirected-link-breed [ undirected-edges undirected-edge ]
directed-link-breed [ directed-edges directed-edge ]
O> crt 3 [ set color blue ]
O> crt 3 [ set color red ]
map count nw:louvain-communities => [1 1 1 1 1 1]
O> ask turtles [ create-undirected-edges-with other turtles ]
sort map count nw:louvain-communities => [6]
O> foreach [[0 1] [1 2] [2 0] [3 4] [4 5] [5 3]] [ [ends] -> ask turtle first ends [ create-directed-edge-to turtle last ends ] ]
sort map count nw:louvain-communities => [3 3]
louvain-communities-respect-random-seed
extensions [ nw ]
globals [ comms ]
O> crt 100 [ create-links-with n-of 2 other turtles ]
O> random-seed 0
O> set comms nw:louvain-communities
O> random-seed 0
comms = nw:louvain-communities => true
O> random-seed 0
comms = nw:louvain-communities => true
O> random-seed 0
comms = nw:louvain-communities => true
O> random-seed 0
comms = nw:louvain-communities => true
louvain-communities-more-seed-tests
extensions [ nw ]
globals [ comms other-comms ]
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
O> set comms map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
comms = map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities => true
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
comms = map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities => true
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
comms = map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities => true
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
comms = map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities => true
O> ct random-seed 0 nw:generate-watts-strogatz turtles links 100 4 0.1
comms = map [ [ts] -> sort [ who ] of ts ] nw:louvain-communities => true
# tests to make sure undirected edges are worth twice directed edges
mixed-separate-components
extensions [ nw ]
directed-link-breed [directed-edges directed-edge]
undirected-link-breed [undirected-edges undirected-edge]
O> crt 100 [ set color blue ]
O> crt 100 [ set color red ]
O> ask turtles [ create-directed-edges-to other turtles with [ color = [ color ] of myself ] ]
O> ask turtles [ create-undirected-edges-with other turtles with [ color != [ color ] of myself ] ]
nw:modularity nw:weak-component-clusters => 0