Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ECMM466: Social Networks and Text Analysis

2022

Coursework I

 

Questions:

1. Analyze a Network

(15 points)

(1.a) Load the Network.

Please load the network form the edge-list file: infect-dublin .edges as Gx. This is the edges of an undirected binary network of contact. You can find the file infect-dublin .edges on Ele page of the course ECMM466.

Note:  This dataset contains the daily dynamic contact networks collected during the Infectious SocioPatterns event that took place at the Science Gallery in Dublin, Ireland, during the artscience exhibition INFECTIOUS: STAY AWAY.  From:  L .  Isella  et  al.,  What’s  in  a  crowd?   Analysis  of face-to-face  behavioral networks, Journal of Theoretical Biology 271  (2011) .

(1.b) Plot the Network Adjacency Matrix.

(1.c) Plot the Degree distribution.

(1.d) Plot the Degree sequence. Using the powerlaw package on python, plot the degree sequence and check if has a powerlaw distribution.

(1.e) Is the Network you are analyzing Assortative or Disassortative?

Please motivate your answer in write.   (You can use plots and/or mathematical evaluation to support your answer).


2.  Centrality and Community Detection

(40 points)

(2.a) Centralities.

Explain the degree centrality, and the eigenvector centrality. What are the differences between the two? Provide one practical example for the degree centrality and one for the eigenvector centrality. When is useful to apply each of two metrics. Motivate your answers.

(2.b.i) Closeness Centrality.

Code the function centrality_closeness(),that inputs the network and returns the closeness centrality of each nodes. (Do not use the function built in closeness centrality function in networkx or other python packages, you have to code it by yourself. You can use the the shortest path function already implemented in any other python packages different from networkx.)


(2.b.ii) Closeness Centrality.

Using Gx, compare the result of your metrics centrality_closeness() with the betweenness centrality, with a scatter plot on the x closeness centrality measure and y the betweenness centrality one. Is there any correlation? Why? explain your answer.

(2.c) Centrality Measure.

Please consider now the network Gx loaded in question 1.a..   Imagine that Gx is now representing a social network, similar to Facebook, Instagram or WeChat.  You have to advertise a product and you have budget to hire only one influencer (i.e. a node in the network Gx). Using the metrics within the centrality metrics we saw during the lectures ECMM466 and the Labs, suggest the influencer you will hire (as Node id).  Motivate your decision.  Finally plot the network having the nodes color coded with their centrality measure and with the node selected as influence colored in dark green.

(2.d) Influencer Ego network .

Define a function Draw_ego_network that inputs a network G  (a networkx network), a network layout  (as list  of nodes  position),  and  a  node  id  and  the  maximum  distance  of interaction  (as  int).   The  function Draw_ego_network will output the network plot of G outlining  (with a different color and bigger size) the node selected, and the ego network of the node id coloring in different color the links and the nodes depending on the interaction distance.

Test your function with the network Gx, the node id of the influencer selected in the question 2.c, a network layout of your choice (that will improve the readability of the plot) and interaction distance 2. (See the expected output at the end.)

(2.e) Community Detection. Decide and declare a community algorithm of your choice among the ones we saw during the lectures ECMM466. Imagine that G is now representing a topological map of distances between the nodes. A link between any pair of nodes means that you can travel between the pair of nodes in a hour. If a link is not present you can not travel between the nodes. You are been hired by a delivery agency to select the perfect location for its new two garages.  The delivery agency wants to start its business serving the two biggest community of the network Gx based on the algorithm you decided. Where are you suggesting to build the two garages (node id)? Which metric are you using to motivate you answer? Why? Plot the sub-network of the two selected communities, with the metric you selected, outlining with different color and size the nodes you proposed as garages’ locations. (As possible output of the plot see the labs.)

(2.f) Adjacency matrix of the Community Detection.

Define a function plot_adj_comm() that inputs a network G, a community detection metrics and outputs the adjacency matrix reordered depending on the clusters membership and cluster size (from little cluster to the bigger cluster). Plots the adjacency matrix using the same community detection algorithm you used in question 2.e. Graphically outline all the clusters.



3.  SI Model

(45 points)

In this section you have to create your functions and you cannot use any pre-written code or python libraries that perform SI/SIR/SIS simulation. If you will use python libraries that implement SI/SIR models or similar you will have zero point.

(Note:  sampling matters.  To run 100 simulations a pc should not take more than 3 minutes.  Please select a correct amount of simulations to validate your analysis.)

(3.a) SI Model.

Define the function SI_model() that inputs:

• G (Network as networkx)

•  initial_infecteds (as list of nodes ID)

• beta (trasmission probability as float)

• t_simulation (simulation iteration time as int)

Output: A dictionary that contains the nodes status at each time steps. In this case the status can be:

•  ’S’ as susceptible.

•  ’I’ as Infected.

Using the network Gx and beta=0 .01, t_simulation=300, initial_infecteds= (list  of  3 random nodes) plot the number of user in each status at each time step of the simulation.

(3.b) SIR Model.

It has been discovered that the all the infected after a given recovery time became immune. If a node is immune and it is in contact with the infected node it does not became infected, and it will not spread the infection!

Define the function SIR_model() that inputs:

• G (a Network as networkx)

•  initial_infected (nodes that are infected at time=0 as list of nodes ID)

• beta (trasmission probability as float)

• t_simulation (simulation iteration time as int)

• recovery_time (nodes that are vaccinated as list of nodes ID)

• the number of days needed for the recovery.

Output: a dictionary that contains the nodes status at each time steps. In this case the status can be:

•  ’S’ as susceptible.

•  ’I’ as Infected.

•  ’R’ as Recovered.

Using the network Gx and beta=0 .005, t_simulation=300, initial_infected= (list  of  3 random nodes), recovery_time=15, plot the number of users in each status at each simulation time step.

(3.c) Second Wave.

After 100 days a second waves of the same infection start to spread on your network. Starting from the day 100: 30 people get infected randomly in your network. Keep fixed the simulation propose by the SIR Model in question 3.b. Randomly add at day 100, 30 new infections. If a person is infected by the second wave this set of rules applied:

• if the person was ’S’ it became infected.

• if the person was ’I’ you need to set to zero the recovery time (it will have to wait 15 days to became immune).

•  ’R’ remain recovered and it is immune to the second wave.

This new infection is more easy to transmit and it has a beta=0 .02!

(3.d) Remarks.

Plot all the simulation together and make your final remarks on the simulation result of SI, SIR and Second Wave. How does the second wave affect your population? Please make your consideration in writing.

 

Expected output


 

 

Figure 1: Expected visual output Q. 2.d (in some extent)

 

 

 

Figure 2: Expected visual output Q. 2.f adjacency matrix resorted with clustering analysis (in some extent)


 

 

 

Figure 3: Expected visual output for Q. 1.e (in some extent)

 


 

 

 

Figure 4: Expected visual output Q. 3.b (in some extent note it is missing the second wave)