Yet another implementation of Watts and Strogatz Small World Algorithm

1 collaborator

julien siebert (Author)

Tags

code example

Tagged by julien siebert almost 11 years ago

small world

Tagged by julien siebert almost 11 years ago

watts strogatz

Tagged by julien siebert almost 11 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 1523 times • Downloaded 73 times • Run 0 times

WHAT IS IT?

It is an implementation of the Watts and Strogatz Small World Algorithm. Mainly for example and discussion purposes.

HOW IT WORKS

First the nodes are created. Then a regular lattice of K nearest neighbours. Finally with a probability beta each link is rewired to a 'not-yet-neighbour' node with id > the current node.

See Watts and Strogatz Algorithm http://en.wikipedia.org/wiki/WattsandStrogatz_model

HOW TO USE IT

Set the number of nodes. Set the parameters K and Beta. Choose the radius of the layout.

THINGS TO NOTICE

(suggested things for the user to notice while running the model)

EXTENDING THE MODEL

You can use this code sample

CREDITS AND REFERENCES

http://en.wikipedia.org/wiki/WattsandStrogatz_model

Click to Run Model

```to setup
clear-all
;; creates all the nodes
set-default-shape turtles "circle"
create-turtles  nb-nodes  [set size 0.5 set color gray]
;; arrange them in a circle in order by who number
layout-circle (sort turtles) radius
;; create the link between the nodes with the Watts and Strogatz algorithm
;; set the simulation time to 0 (plot things)
reset-ticks
;;  go
end

;;to go
;;  tick
;;end

;; create the links among nodes (Watts and Strogatz algorithm), add weight and color

;; create a regular lattice
let n 1
while [ n <= K ]
[
ifelse who < (count turtles - K)
[
ifelse (random-float 1) < beta
[
]
[
]
]
[
]
set n (n + 1)
]
]
end

create-link-with turtle ((who + n) mod count turtles)
[
set color blue
]
end

;; create a link with another 'not-yet linked' node whose id > caller id

let myid who
let other-node one-of other turtles with [(who > myid) and (not link-neighbor? turtle myid)]
if other-node != nobody
[
[
set color red
]
]
end
```

There are 2 versions of this model.