Libraries‎ > ‎Library‎ > ‎Social network‎ > ‎

Constant social network

BehaviourComposer: ignore everything before this. 

Begin micro-behaviour

Begin description:

Create a social network where everyone has the same number of bi-directional links.

End description

Constant social network

Begin NetLogo code:

substitute-text-area-for average-acquaintance-count-text-area 4  
substitute-text-area-for community-expression all-individuals
do-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 entire-community 
                             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

Variants

You 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 behaviours

The Power law social network behaviour assigns acquaintances to each individual to create a power law distribution.

How this works

First 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.

History

Constant social network was implemented by Ken Kahn on 3 February 2011. Updated 11 May 2011.

BehaviourComposer: ignore everything after this.

Comments