from IPython.display import Image
%matplotlib inline
%load_ext sage
from influence import influence_sim,infdif_sim,polinfluence_sim,cl_influence_sim
# Connected Erdos-Renyi random graph
nodes = 25
p = 0.2
iterations = 500
# Experiment B1: INFLUENCE
# Susceptibility of all nodes (low)
sa = 0.1
influence_sim(nodes,p,sa,iterations)
# Experiment B2: INFLUENCE
# Susceptibility of all nodes (high)
sa = 0.9
influence_sim(nodes,p,sa,iterations)
# Experiment B3: INFLUENCE
# DIFFUSION BY INFLUENCE with heterogeneous susceptibilities
# Susceptibility of node 0 (the lowest)
sa = 0.
# Susceptibility of all other nodes (very low)
sb = 0.1
infdif_sim(nodes,p,sa,sb,iterations)
# Experiment B4: INFLUENCE
# DIFFUSION BY INFLUENCE with heterogeneous susceptibilities
# Susceptibility of node 0 (low)
sa = 0.2
# Susceptibility of all other nodes (medium)
sb = 0.5
infdif_sim(nodes,p,sa,sb,iterations)
# Experiment B5: INFLUENCE
# DIFFUSION BY INFLUENCE with heterogeneous susceptibilities
# Susceptibility of node 0 (medium)
sa = 0.4
# Susceptibility of all other nodes (low)
sb = 0.2
infdif_sim(nodes,p,sa,sb,iterations)
# Experiment B6: INFLUENCE
# DIFFUSION BY INFLUENCE with heterogeneous susceptibilities
# Susceptibility of node 0 (high)
sa = 0.8
# Susceptibility of all other nodes (higher)
sb = 0.9
infdif_sim(nodes,p,sa,sb,iterations)
# Experiment B7: INFLUENCE
# DIFFUSION BY INFLUENCE with heterogeneous susceptibilities
# Susceptibility of node 0 (high)
sa = 0.8
# Susceptibility of all other nodes (less high)
sb = 0.7
infdif_sim(nodes,p,sa,sb,iterations)
# Experiment B8: INFLUENCE
# CONTRARIAN INFLUENCE
# Susceptibility of all nodes (low)
sa = 0.1
polinfluence_sim(nodes,p,sa,iterations)
# Experiment B9: INFLUENCE
# CONTRARIAN INFLUENCE
# Susceptibility of all nodes (medium)
sa = 0.5
polinfluence_sim(nodes,p,sa,iterations)
# Experiment B10: INFLUENCE
# CONTRARIAN INFLUENCE
# Susceptibility of all nodes (high)
sa = 0.9
polinfluence_sim(nodes,p,sa,iterations)
# Experiment B11: INFLUENCE
# SEGREGATED INFLUENCE: The interval of attributes [0,1] is divided in three zones:
# [0,1/3), the "left",
# [1/3, 2/3), the "center",
# [2/3,1], the "right".
# * Persons in either one of the three zones interact as in Experiment 1 as far as their neighbors' attributes
# lie in the same zone with them.
# * Otherwize, persons in the "left" interact only with persons in the "center left" [1/3,1/2],
# persons in the "right" interact only with persons in the "center right" [1/2,2/3], while persons in the
# "left" do not interact with persons in the "right."
# The outcome is that persons' attributes are stabilized in a multiplicity of heterogeneous positions in the
# interval of attributes, i.e., complete dissensus emerges.
# Susceptibility of all nodes (high)
sa1 = 0.9 # high susceptibility inside the "left" and the "right"
sa2 = 0.1 # low susceptibility among "left" and "center left" and among "right and center right".
cl_influence_sim(nodes,p,sa1,sa2,iterations)