Yet another implementation of Watts and Strogatz Small World Algorithm

Yet another implementation of Watts and Strogatz Small World Algorithm preview image

1 collaborator

Default-person julien siebert (Author)

Tags

code example 

Tagged by julien siebert over 9 years ago

small world 

Tagged by julien siebert over 9 years ago

watts strogatz 

Tagged by julien siebert over 9 years ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 1434 times • Downloaded 64 times • Run 0 times
Download the 'Yet another implementation of Watts and Strogatz Small World Algorithm' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


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)

THINGS TO TRY

EXTENDING THE MODEL

You can use this code sample

NETLOGO FEATURES

RELATED MODELS

CREDITS AND REFERENCES

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

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

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
  link-nodes
  ;; 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

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

to normal-link [n]
  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 

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

There are 2 versions of this model.

Uploaded by When Description Download
julien siebert over 9 years ago I have added a plot to show the node-degree distribution Download this version
julien siebert over 9 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Yet another implementation of Watts and Strogatz Small World Algorithm.png preview Preview for 'Yet another implementation of Watts and Strogatz Small World Algorithm' over 9 years ago, by julien siebert Download

This model does not have any ancestors.

This model does not have any descendants.