Description
In this project, we will study the various properties of social networks. In the first part of the project, we will study an undirected social network (Facebook). In the second part of the project, we will study a directed social network (Google +).

Facebook network
In this project, we will be using the dataset given below:
http://snap.stanford.edu/data/egonetsFacebook.html
The Facebook network can be created from the edgelist file (facebook combined.txt)
1.1 Structural properties of the facebook network
Having created the facebook network, we will study some of the structural properties of the network. To be specific, we will study
Degree distribution
Question 1: Is the facebook network connected? If not, find the giant connected component (GCC) of the network and report the size of the GCC.
Question 2: Find the diameter of the network. If the network is not connected, then find the diameter of the GCC.
Question 3: Plot the degree distribution of the facebook network and report the average degree.
Question 4: Plot the degree distribution of question 3 in a loglog scale.
Try to fit a line to the plot and estimate the slope of the line.
1.2 Personalized network
A personalized network of an user v_{i} is defined as the subgraph induced by v_{i} and it’s neighbors. In this part, we will study some of the structural properties of the personalized network of the user whose graph node ID is 1 (node ID in edgelist is 0). From this point onwards, whenever we are refering to a node ID we mean the graph node ID which is 1 + node ID in edgelist.
Question 5: Create a personalized network of the user whose ID is 1. How many nodes and edges does this personalized network have?
Question 6: What is the diameter of the personalized network? Please state a trivial upper and lower bound for the diameter of the personalized network.
Question 7: In the context of the personalized network, what is the meaning of the diameter of the personalized network to be equal to the
2
upper bound you derived in question 6. What is the meaning of the diameter of the personalized network to be equal to the lower bound you derived in question 6?
1.3 Core node’s personalized network
A core node is defined as the nodes that have more than 200 neighbors. For visualization purpose, we have displayed the personalized network of a core node below.
An example of a personal network. The core node is shown in black.
In this part, we will study various properties of the personalized network of the core nodes.
Question 8: How many core nodes are there in the Facebook network. What is the average degree of the core nodes?
1.3.1 Community structure of core node’s personalized network
In this part, we study the community structure of the core node’s personalized network. To be specific, we will study the community structure of the personalized network of the following core nodes:
Node ID 1 Node ID 108 Node ID 349 Node ID 484
Node ID 1087
Question 9: For each of the above core node’s personalized network, find the community structure using FastGreedy, EdgeBetweenness, and Infomap community detection algorithms. Compare the modularity scores of the algorithms. For visualization purpose, display the community structure of the core node’s personalized networks using colors. Nodes belonging to the same community should have the same color and nodes belonging to different communities should have different color. In this question, you should have 15 plots in total.
1.3.2 Community structure with the core node removed
In this part, we will explore the effect on the community structure of a core node’s personalized network when the core node itself is removed from the personalized network.
Question 10: For each of the core node’s personalized network(use same core nodes as question 9), remove the core node from the personalized network and find the community structure of the modified personalized network. Use the same community detection algorithm as question 9.
Compare the modularity score of the community structure of the modified personalized network with the modularity score of the community structure of the personalized network of question 9. For visualization purpose, display the community structure of the modified personalized network using colors. In this question, you should have 15 plots in total.
1.3.3 Characteristic of nodes in the personalized network
In this part, we will explore characteristics of nodes in the personalized network using two measures. These two measures are stated and defined below:
Embeddedness of a node is defined as the number of mutual friends a node shares with the core node.
Dispersion of a node is defined as the sum of distances between every pair of the mutual friends the node shares with the core node. The distances should be calculated in a modified graph where the node (whose dispersion is being computed) and the core node are removed.
For further details on the above characteristics, you can read the paper below:
http://arxiv.org/abs/1310.6753
Question 11: Write an expression relating the Embeddedness of a node to it’s degree.
Question 12: For each of the core node’s personalized network (use the same core nodes as question 9), plot the distribution of embeddedness and dispersion. In this question, you will have 10 plots.
Question 13: For each of the core node’s personalized network, plot
the community structure of the personalized network using colors and highlight the node with maximum dispersion. Also, highlight the edges incident to this node. To detect the community structure, use FastGreedy algorithm. In this question, you will have 5 plots.
Question 14: Repeat question 13, but now highlight the node with
maximum embeddedness and the node with maximum _{embeddedness}^{dispersion}. Also, highlight the edges incident to these nodes
Question 15: Use the plots from questions 13 and 14 to explain the characteristics of a node revealed by each of this measure.
1.4 Friend recommendation in personalized networks
In many social networks, it is desirable to predict future links between pairs of nodes in the network. In the context of this Facebook network it is equivalent to recommending friends to users. In this part of the project, we will explore some neighborhoodbased measures for friend recommendation. The network that we will be using for this part is the personalized network of node with ID 415.
1.4.1 Neighborhood based measure
In this project, we will be exploring three different neighborhoodbased measures. Before we define these measures, let’s introduce some notation:
S_{i} is the neighbor set of node i in the network S_{j} is the neighbor set of node j in the network
Then, with the above notation we define the three measures below:
Common neighbor measure between node i and node j is defined as
CommonNeighbors(i; j) = jS_{i} \ S_{j}j
Jaccard measure between node i and node j is defined as
Jaccard(i; j) = ^{jS}^{i} ^{\} ^{S}^{j}^{j}
jS_{i} [ S_{j}j
AdamicAdar measure between node i and node j is defined as
AdamicAdar(i; j) =
X 1
_{k2S}_{i}_{\S}_{j} ^{log(jS}k^{j)}
1.4.2 Friend recommendation using neighborhood based measures
We can use the neighborhood based measures defined in the previous section to recommend new friends to users in the network. Suppose we want to recommend t new friends to some user i in the network using Jaccard measure. We follow the steps listed below:

For each node in the network that is not a neighbor of i, compute the jaccard measure between the node i and the node not in the neighborhood of i
Compute Jaccard(i; j) 8j 2 S_{i}^{C}

Then pick t nodes that have the highest jaccard measure with node i and recommend these nodes as friends to node i
1.4.3 Creating the list of users
Having defined the friend recommendation procedure, we can now apply it to the personalized network of node ID 415. Before we apply
the algorithm, we need to create the list of users who we want to recommend new friends to. We create this list by picking all nodes with degree 24. We will denote this list as N_{r}.
Question 16: What is jN_{r}j?
1.4.4 Average accuracy of friend recommendation algorithm
In this part, we will apply the 3 different types of friend recommendation algorithms to recommend friends to the users in the list N_{r}. We will define an average accuracy measure to compare the performances of the friend recommendation algorithms.
Suppose we want to compute the average accuracy of the friend recommendation algorithm. This task is completed in two steps:

Compute the average accuracy for each user in the list N_{r}

Compute the average accuracy of the algorithm by averaging across the accuracies of the users in the list N_{r}
Let’s describe the procedure for accomplishing the step 1 of the task. Suppose we want to compute the average accuracy for user i in the list N_{r}. We can compute it by iterating over the following steps 10 times and then taking the average:
1. Remove each edge of node i at random with probability 0.25. In this context, it is equivalent to deleting some friends of node i. Let’s denote the list of friends deleted as R_{i}
2. Use one of the three neighborhood based measures to recommend jR_{i}j new friends to the user i. Let’s denote the list of friends recommended as P_{i}
3. The accuracy for the user i for this iteration is given by ^{jP}i^{\R}i^{j}
jR_{i}j
By iterating over the above steps for 10 times and then taking the average gives us the average accuracy of user i. In this manner, we compute the average accuracy for each user in the list N_{r}. Once we have computed them, then we can take the mean of the average accuracies of the users in the list N_{r}. The mean value will be the average accuracy of the friend recommendation algorithm.
Question 17: Compute the average accuracy of the friend recommendation algorithm that uses:
Common Neighbors measure Jaccard measure
Adamic Adar measure
Based on the average accuracy values, which friend recommendation algorithm is the best?

Google+ network
In this part, we will explore the structure of the Google+ network. The dataset for creating the network can be found in the link below:
http://snap.stanford.edu/data/egonetsGplus.html
Create directed personal networks for users who have more than 2 circles. The data required to create such personal networks can be found in the file named gplus.tar.gz.
Question 18: How many personal networks are there?
Question 19: For the 3 personal networks (node ID given below), plot the indegree and outdegree distribution of these personal networks.
Do the personal networks have a similar in and out degree distribution. In this question, you should have 6 plots.
109327480479767108490 115625564993990145546 101373961279443806744
2.1 Community structure of personal networks
In this part of the project, we will explore the community structure of the personal networks that we created and explore the connections between communities and user circles.
Question 20: For the 3 personal networks picked in question 19, extract the community structure of each personal network using Walktrap community detection algorithm. Report the modularity scores and plot the communities using colors. Are the modularity scores similar? In this question, you should have 3 plots.
Having found the communities, now we will explore the relationship between circles and communities. In order to explore the relationship, we define two measures:
Homogeneity Completeness
Before, we state the expression for homogeneity and completeness, let’s introduce some notation:
C is the set of circles, C = fC_{1}; C_{2}; C_{3}; g
K is the set of communities, K = fK_{1}; K_{2}; K_{3}; g a_{i} is the number of people in circle C_{i}
b_{i} is the number of people in community K_{i} with circle information N is the total number of people with circle information
C_{ji} is the number of people belonging to community j and circle i
Then, with the above notation, we have the following expressions for the entropy

jCj
a_{i}a_{i}
X_{i}
(1)
H(C) =
N
log(
N
)
=1
jKj 
b_{i} 
b_{i} 

X_{i} 

H(K) = 
_{N} log(_{N} ) 

=1 

and conditional entropy 

jKj jCj 
^{C}ji 
^{C}ji 

XX_{j} 

N 
log( _{b}_{j} 
) 

H(CjK) = 

=1 i=1 

jCj jKj 
^{C}ji 
^{C}ji 

XX_{i} 

N 
log( _{a}_{i} 
) 

H(KjC) = 

=1 j=1 
(2)
(3)
(4)
Now we can state the expression for homogeneity, h as

h = 1
H(CjK)
(5)
H(C)
and the expression for completeness, c as

c = 1
H(KjC)
(6)
H(K)
Question 21: Based on the expression for h and c, explain the meaning of homogeneity and completeness in words.
Question 22: Compute the h and c values for the community structures of the 3 personal network (same nodes as question 19). Interpret the values and provide a detailed explanation.
11
Please submit a zip file containing your codes and report to CCLE. The zip file should be named as “Project2_UID1_…_UIDn.zip” where UIDx are student ID numbers of team members. If you had any questions you can post on piazza.
12