# Map represented as a network (rewiring equivalent to application of map)

### 1 collaborator

julien siebert (Author)

### Tags

code example

Tagged by julien siebert almost 11 years ago

fun

Tagged by julien siebert almost 11 years ago

math

Tagged by julien siebert almost 11 years ago

networks

Tagged by julien siebert almost 11 years ago

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

## Comments and Questions

Click to Run Model

```breed [ nodes node ] ;; the turtle are called nodes

nodes-own [ current-next-node new-next-node ]

globals [ continue? ]  ;; is it possible to apply the transformation once again

to setup
clear-all
;; creates all the nodes
set-default-shape nodes "circle"
let size-nodes ( 0.75 * max-pxcor / nb-nodes)
create-nodes nb-nodes [set label who set size size-nodes ]
;; show the nodes with a circular layout
;; link the nodes
;; set up global parameters
set continue? true
;; set simulation time to 0
reset-ticks
end

;; create an ordered cycle between nodes (e.g. 0 -> 1 -> 2 -> 3 ... -> (nb-nodes - 1) -> 0 )
[
set current-next-node turtle ((who + 1) mod count nodes)
]
end

to apply-transformation
;; rewire the links
if continue?
[
;; we can still apply the transformation
[
;; compute the new "next-node"
set new-next-node (get-next-node nb-hop)  ;; get the next n-hop node
]

;; remove the links

;; change the current pointer to the next-node by the newly computed one
ask nodes [ set current-next-node new-next-node ]

;; link the nodes
]
end

;; create a link between the node and its current next-node
ifelse current-next-node != self
[
[
set color [color] of end2
]
]
[
set continue? false
]
end

to-report get-next-node [ n ]
;; return the n-hop node (recursive function)
let result nobody
ifelse n = 0
[
report self
]
[
set n n - 1
set result get-next-node n
]
]
report result
end
```

There is only one version of this model, created almost 11 years ago by julien siebert.

## Attached files

File Type Description Last updated
Map represented as a network (rewiring equivalent to application of map).png preview Preview for 'Map represented as a network (rewiring equivalent to application of map)' almost 11 years ago, by julien siebert Download

This model does not have any ancestors.

This model does not have any descendants.