我创建了一个由10个节点组成的小型网络,并相互链接。然后我使用网络扩展计算每个节点的中介中心性。 现在,我想实现随机游走算法。 首先,当我创建walker时,我想将它们放在具有最大值介于中间的一个节点上。 然后我想将walker移动到具有最大值betweennes的link-neighbor的新位置。 但是,我不知道如何实现这个逻辑,请指导和帮助我。 这是我的代码:
extensions [ nw ]
breed [ nodes node ]
breed [ walkers walker ]
walkers-own [ location ]
to setup
clear-all
make-nodes
end
to go
random-walk
end
to make-nodes
create-nodes 10 [
set shape "circle"
set color white
setxy (random-xcor * 0.95) ( random-ycor * 0.95)
]
ask nodes [
create-link-with one-of other nodes ]
end
to make-walkers
create-walkers 3 [
set color green
**set location one-of nodes**
move-to location
]
reset-ticks
end
to random-walk
ask links [ set thickness 0 ]
ask walkers [
**let new-location one-of [link-neighbors] of location**
move-to new-location
set location new-location
ask location [
set color red]
tick
end
to betweenness
centrality [ [] -> nw:betweenness-centrality ]
end