BehaviourComposer: ignore everything before this. I create an entire social network where everyone has the same number of acquaintances.Begin micro-behaviourConstant social network Begin NetLogo code:substitute-text-area-for average-acquaintance-count-text-area 4 substitute-text-area-for community-expression all-individualsdo-after-setup [let average-acquaintance-count average-acquaintance-count-text-area output-print (word "Initialising the social network so everyone has exactly " average-acquaintance-count " acquaintances.") let entire-community community-expression let total-population count entire-community if total-population < average-acquaintance-count + 1 [output-print "Too few individuals to create a network." stop] ask entire-community [let me self while [count link-neighbors < average-acquaintance-count] [let x one-of other all-individuals with [count link-neighbors < average-acquaintance-count and not link-neighbor? me] if x = nobody [stop] create-link-with x]] output-print "Initialisation completed."]End NetLogo code VariantsYou can edit the text areas to change the average number of acquaintances per person or to change the set of individuals that are to be linked together. Related behavioursThe Power law social network behaviour assigns acquaintances to each individual to create a power law distribution. How this worksFirst this computes the total number of links which is half of the population times the average number of acquaintances. (Each link represents an acquaintance relationship for both ends of the link, hence we divide by two.) For each link that needs to be added it selects both ends randomly from a list that initially contains the entire population. If  the two individuals are already linked it selects again. When a link is added then the individuals at the ends of the link are added to the list. This makes those with connections more likely to gain new connections. This is known as preferential attachment and it generates a power law distribution. HistoryThis was implemented by Ken Kahn on 3 February 2011. Updated 11 May 2011. BehaviourComposer: ignore everything after this. |