'How to visualize two (or more) subnetworks in Netlogo using circle layout
I would like to know if it could be possible to visualize two distinct subnetworks (e.g., made up by turtles white and another one made up by turtles orange) with some links between them.
Visually, they should look like two networks having layout circle (layout-circle
), for instance.
Currently I can visualize only one network made up by turtles orange and white (to give you an idea: https://www.dreamstime.com/royalty-free-stock-photos-people-join-merge-social-two-circles-as-network-business-groups-image30895498).
Any help would be great. Thanks.
An example of what I am trying to do is shown below.
to WS [N k p]
create-types1 N [
set color white
setxy random-xcor random-ycor
]
create-types2 N [
set color orange
setxy random-xcor random-ycor
]
layout-circle sort types1 max-pycor * 0.9
let lis (n-values (k / 2) [ [i] -> i + 1 ])
ask types1 [
let w who
foreach lis [ [i] -> create-link-with (type1 ((w + i) mod N)) ]
]
rewire p
end
to rewire [p]
ask links [
let rewired? false
if (random-float 1) < p
[
let node1 end1
if [ count link-neighbors ] of node1 < (count types1 - 1)
[
let node2 one-of types1 with [ (self != node1) and (not link-neighbor? node1) ]
ask node1 [ create-link-with node2 [ set rewired? true ] ]
]
]
if (rewired?)
[
die
]
]
end
The code above should create a small world network where there are two types of breeds: type1
and type2
, distinguished by the color.
Instead of visualizing the types within the same network, I would like to create one small world network for type1 and another one for type2. These two networks would be linked by a few links that there might exist between the two types.
Solution 1:[1]
Are you looking for something along these lines? I create both circles independently and then move them to their desired position, as well as creating the links separately for both types.
breed [types1 type1]
breed [types2 type2]
to WS [N k p]
create-types1 N [
set color white
]
create-types2 N [
set color orange
]
layout-circle sort types1 max-pycor * 0.5
ask types1 [setxy xcor - 5.5 ycor]
layout-circle sort types2 max-pycor * 0.5
ask types2 [setxy xcor + 5.5 ycor]
let lis (n-values (k / 2) [ [i] -> i + 1 ])
ask types1 [
let w who
foreach lis [ [i] -> create-link-with (type1 ((w + i) mod N)) ]
]
;let links1 link-set [my-links] of types1
ask types2 [
let w who
foreach lis [ [i] -> create-link-with (type2 ((w + i) mod N + N)) ]
]
;let links2 link-set [my-links] of types2
end
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |