Diffusione in social network and utility function
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
ABOUT
This model aims to represent the diffusion of an idea, a state of humour, a decision within a social context where community members place their beliefs on other community members. The structure used to represent the social context is the network characterized by the presence of weighted and directed links.
How it works
The simulation uses real-world network models to connect members:
- The preferencial attachment network generates a network of members that have a skewed population with a few highly-connected nodes and a lot of loosely-connected nodes, this type of network is generally taken into consideration to represent the social influence in real-world (district, small city, neighbourhood).
- The Watts-Strogatz network generates a small-world network that has concise paths between any connected network members, and it applies to real and virtual social networks and physical networks such as airports or electricity of web-traffic routings.
- The random network generates a network in which each member has certainty probability to be connected. This applies in those contexts which involve a high tendency of individuals to associate and bond with similar others, which results in similar properties among neighbours.
- The distribution of idea represents the summation of the whole probabilities
- The frequency of weight is a histogram that represents the links' weights
- The individual utility represents the utility function of a single individual, wether the watch? bar is switched-on. It can be written as y(i) = max p(i) * w(i)
- The social utility represents the social utility function as a summation of the individuals' utilities and it can be written as Y = summation y(i).
As the curve goes above the threshold, the agents' utility will be more significant to choose red; instead, if the curve goes below the threshold, the agents' utility will be more significant not to choose red.
Measures [3]
- The modularity measures the strength of division of the network into clusters
- The "detect communities" button detects the community structure present in the social network by highlighting with different color
- The betweeness centrality measures the sum of the proportion of shortest paths between members of any other pairs that passes through each node
- The eigenvector centrality measures the amount of influence that a member reaches from the social context and goes from 0 to 1
- The closeness centrality measures the inverse of the average of each member's distances to all other members
- The "print adjacency matrix" button saves a .txt file with a matrix representing the nodes and its connection
CREDITS AND REFERENCES
[1] Goldenberg D. (2021). "Social Network Analysis: From Graph Theory to Applications with Python". Available online at: https://towardsdatascience.com/social-network-analysis-from-theory-to-applications-with-python-d12e9a34c2c7
[2] Jackson M.O (2008). "Social and economic networks". Princeton University Press. Pp 287 - 327
[3] Uri Wilensky. "Nw General Examples". Available online at: https://ccl.northwestern.edu/netlogo/models/NWGeneralExamples
Comments and Questions
extensions [nw] ; network extention to generate real world networks breed [group person] ;turtles are called group, individuals are called person directed-link-breed [influences influence] ;directed link are called influences links-own [weight alternative] ;weight -> random weight assigned to each directed link, alternaive -> weight * p of end1 value to transfer to end2 group-own [p utility preferences oldsum] ;p -> probability to assume red idea, utility -> individual utility function, preferences -> list of alternatives, oldsum -> spreading value of influence globals [changing] ;stopping condition ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; SETUP ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to setcounts ;stopping condition set changing true set members members end ;generation of the "real world" networks to setup-pa ;generate preferential-attachment ca setcounts nw:generate-preferential-attachment group influences members 1 [ ;generates network according to the Barabási–Albert algorithm set color grey ;each turtle starts with the same grey color setxy random-xcor random-ycor ;turtles are positioned into the world randomly set shape "person" set size 2] assign-weight assign-p show-label watch-one reset-ticks end to setup-small-world ;generate small-world network ca setcounts nw:generate-watts-strogatz group influences members 1 1 [ ;generates network according to the Kleinberg Model set color grey setxy random-xcor random-ycor set shape "person" set size 2] assign-weight assign-p show-label watch-one reset-ticks end to setup-random ;generate random network ca setcounts nw:generate-random group influences members 1 [ ;generates network according to the Erdős–Rényi model set color grey setxy random-xcor random-ycor set shape "person" set size 2] assign-weight assign-p show-label watch-one reset-ticks end to assign-weight ;assign random weight to links in range [ 0 , 1 ] ask influences [set weight ( round (1000 * random-float 1) / 1000) ] ;this computation allows to avoid tiny variations end to assign-p ;assign random probability to agents in range [ 0 , 1 ] ask group [set p random 2 ] ask group [ if (p = 1) [ set color red ] ] ;changing to p=1 for red, 1 - p for grey ask group [ if (p = 0) [ set p -1 set color grey]] end to show-label ;is the switch-bar is on, the probability and weights of each turtles and links are displayed if label? = true [ ask group [set label who] ask influences [ set label precision weight 1 ]] end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; EXPERIMENT ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; to behavior ;behavior works as a neural network and determinants corresponds to the sum of links weights of incoming influence. Each edge will collect ;the netweight value by computing p * w of its starting node and the final node will collect the summation of all the received netweight. if (changing = false) [ print "no longer changing, stop." stop] ;adding stopping condition if (ticks > 20) [stop] ;set up a maximum of 20 iterations set changing false print (word "=================== tick # " ticks " =====================================") ask influences [ if [color = red ] of end1 [set color red ]] ;detect the spread of idea ask group [ let summer 0 ;set up a summer that will be updated each time an individual receive p * w ask my-in-links [ let netweight ( weight * ( [ p ] of end1 ) ) ;spread p * w fron end1 to end2 set summer ( summer + netweight)] ;updating summation of p * w value set oldsum precision oldsum 3 set summer precision summer 3 if (oldsum != summer) [ set changing true ] if (oldsum != summer) and (ticks > 2) [ set changing true ] ;if updating don't change for the next two tick, simulation will stop to avoid cycle set oldsum summer let oldcolor color (ifelse (summer > threshold) [ ;according to the desired threshold set p 1 set color red if ( color != oldcolor) [ print (word who " turned red") ]] ;updating p and color of individual and display changement on command center (summer < threshold * -1) [ set p -1 set color grey if ( color != oldcolor) [ print (word who " turned grey") ]])] show-label individual-utility watch-one tick end to individual-utility ;computation of the individual utility consist on choosing the maximum netweight value, here called alternative. ask influences [set alternative weight * [p] of end1] ;alternative = weight * p and pass throw links ask group [ ifelse my-in-links = true ;asking only to individuals who receive a weighted input [set preferences (list ([alternative] of my-in-links)) ;building a list of alternatives (weight * p) from receiving links set utility max preferences] ;choosing the maximum between alternatives [set utility p]] ;if individuals don't receive any weighted input, his utility will correspond to his initial beliefs end to watch-one ;if the switch-bar is on, it allows to highlight a single individual's behavior in addition to his utility function if watch? = true [ watch person 0] end ;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; PARAMETERS [3] ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;; to-report modularity ;measure modularity related to grey and red members report nw:modularity (list (turtles with [ color = grey ]) (turtles with [ color = red ])) end to save-matrix ;save txt of adjacency matrix that contains the connection between members not taking into consideration the links' weight nw:save-matrix "adjacency-matrix.txt" end to community-detection ;detect community using the louvain method color-clusters nw:louvain-communities end to color-clusters [ clusters ] ;assignment of a color for each cluster ask group [ set color grey ] ask influences [ set color grey - 2 ] let n length clusters let hues n-values n [ i -> (360 * i / n) ] (foreach clusters hues [ [cluster hue] -> ask cluster [ set color hsb hue 100 100 ask my-links with [ member? other-end cluster ] [ set color hsb hue 100 75 ]]]) end to betweenness ;detect betweenness centrality of each member centrality [ -> nw:betweenness-centrality ] end to eigenvector ;as the simulation represent the spread of a concept (due to the placement of beliefs) eigenvector centrality is represented by the inverse of its original sense centrality [ -> 1 - nw:eigenvector-centrality ] end to closeness ;weighted closeness centrality by taking into consideration the weight variable assigned to directed links centrality [ -> nw:weighted-closeness-centrality weight] end to centrality [ measure ] ;assignment of a size according to the centrality measure ask group [ let res (runresult measure) ifelse is-number? res [ set label precision res 2 set size res] [ set label res set size 1 ]] normalize-sizes-and-colors end to normalize-sizes-and-colors ;normalization of the size assigned if count group > 0 [ let sizes sort [ size ] of group let delta last sizes - first sizes ifelse delta = 0 [ ask group [ set size 1 ]] [ ask group [ set size ((size - first sizes) / delta) * 2 + 0.5 ]]] end
There is only one version of this model, created over 2 years ago by Alessia Simone.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.