<<

Chapter 12 Extraction and Analysis of Friendship Relations

Salvatore Catanese, Pasquale De Meo, Emilio Ferrara, Giacomo Fiumara, and Alessandro Provetti

Abstract Online social networks (OSNs) are a unique web and social phenomenon, affecting tastes and behaviors of their users and helping them to maintain/create friendships. It is interesting to analyze the growth and evolution of online social networks both from the point of view of marketing and offer of new services and from a scientific viewpoint, since their structure and evolution may share similarities with real-life social networks. In social sciences, several techniques for analyzing (off-line) social networks have been developed, to evaluate quantitative properties (e.g., defining metrics and measures of structural characteristics of the networks) or qualitative aspects (e.g., studying the attachment model for the network evolution, the binary trust relationships, and the link prediction problem). However, OSN analysis poses novel challenges both to computer and Social scientists. We present our long-term research effort in analyzing Facebook, the largest and arguably most successful OSN today: it gathers more than 500 million users. Access to data about Facebook users and their friendship relations is restricted; thus, we acquired the necessary information directly from the front end of the website, in order to reconstruct a subgraph representing anonymous interconnections among a significant subset of users. We describe our ad hoc, privacy-compliant crawler for Facebook data extraction. To minimize bias, we adopt two different graph mining techniques: breadth-first-search (BFS) and rejection sampling. To analyze the structural properties of samples consisting of millions of nodes, we developed a

S.Catanese¥P.DeMeo¥G.Fiumara Department of Physics, Informatics Section. University of Messina, Messina, Italy E. Ferrara () Department of Mathematics, University of Messina, Messina, Italy A. Provetti Department of Physics, Informatics Section. University of Messina, Messina, Italy Oxford-Man Institute, University of Oxford, Oxford, UK

A. Abraham (ed.), Computational Social Networks: Mining and Visualization, 291 DOI 10.1007/978-1-4471-4054-2 12, © Springer-Verlag London 2012 292 S. Catanese et al. specific tool for analyzing quantitative and qualitative properties of social networks, adopting and improving existing Analysis (SNA) techniques and algorithms.

Introduction

The increasing popularity of online social networks (OSNs) is witnessed by the huge number of users that MySpace, Facebook, etc. acquired in a short amount of time. The growing accessibility of the web, through several media, gives to most users a 24/7 online presence and encourages them to build a online mesh of relationships. As OSNs become the tools of choice for connecting people, we expect that their structure will increasingly mirror real-life society and relationships. At the same time, with an estimated 13 million transactions per second (at peak), Facebook is one of the most challenging computer science artifacts, posing several optimization, scalability, and robustness challenges. The essential feature of Facebook is the friendship relation between participants. It consists, mainly, in a permission to consult each others’ friends list and posted content: news, photos, links, blog posts, etc.; such permission is mutual. In this chapter, we consider the Facebook friendship graph as the (nondirected) graph having FB users as vertices and edges represent their friendship relation. The analysis of OSN connections is a fascinating topic on multiple levels. First, a complete study of the structure of large real (i.e., off-line) communities was impossible or at least very expensive before, even at fractions of the scale considered in OSN analysis. Second, data is clearly defined by some structural constraints, usually provided by the OSN structure itself, w.r.t. real-life relations, often hardly identifiable. The interpretation of these data opens up new fascinating research issues, e.g., is it possible to study OSNs with the tools of traditional , as in Wasserman-Faust [89]and[69]? To what extent the behavior of OSN users is comparable to that of people in real-life social networks [39]? What are the topological characteristics of the relationships network (friendship, in the case of FB) of OSN [4]? And what about their structure and evolution [58]? To address these questions, further computer science research is needed to design and develop the tools to acquire and analyze data from massive OSNs. First, proper social metrics need to be introduced, in order to identify and evaluate properties of the considered OSN. Second, scalability is an issue faced by anyone who wants to study a large OSN independently from the commercial organization that owns and operates it. For instance, last year Gjoka et al. [42] estimated the crawling overhead needed to collect the whole Facebook graph in 44 Tb of data. Moreover, even when such data could be acquired and stored locally (which, however, raises storage issues related to the social network compression [16, 17]), it is nontrivial to devise and implement effective functions that traverse and visit the graph or even evaluate simple metrics. In literature, extensive research has been conducted on sampling techniques for large graphs; only recently, however, studies have shed 12 Extraction and Analysis of Facebook Friendship Relations 293 light on the bias that those methodologies may introduce. That is, depending on the method by which the graph has been explored, certain features may result over/underrepresented w.r.t. the actual graph. Our long-term research on these topics is presented in this chapter. We describe in detail the architecture and functioning modes of our ad hoc Facebook crawler, by which, even on modest computational resources, we can extract large samples containing several milions of nodes. Two recently collected samples of about eight millions of nodes each are described and analyzed in detail. To comply with the FB end-user licence, data is made anonymous upon extraction, hence we never memorize users’ sensible data. Next, we describe our newly developed tool for graph analysis and visualization, called LogAnalysis. LogAnalysis may be used to compute the metrics that are most pertinent to OSN graph analysis, and can be adopted as an open-source, multiplatform alternative to the well-known NodeXL tool.

Background and Related Literature

The task of extracting and analyzing data from Online Social Networks has attracted the interest of many researchers, e.g., in [7, 39, 93]. In this section, we review some relevant literature directly related to our approach. In particular, we first discuss techniques to crawl large social networks and collect data from them (see section “Data Collection in OSN”). Collected data are usually mapped onto graph data structures (and sometimes ) with the goal of analyzing their structural properties. The ultimate goal of these efforts is perhaps best laid out by Kleinberg [56]: topological properties of graphs may be reliable indicators of human behaviors. For instance, several studies show that node distribution follows a power law, both in real and online social networks. That feature points to the fact that most social network participants are often inactive, while few key users generate a large portion of data/traffic. As a consequence, many researchers leverage on tools provided from graph theory to analyze the social network graph with the goal, among others, of better interpreting personal and collective behaviors on a large scale. The list of potential research questions arising from the analysis of OSN graphs is very long; in the following, we shall focus on three themes which are directly relevant to our research: 1. Node Similarity Detection, i.e., the task of assessing the degree of similarity of two users in an OSN (see section “Similarity Detection”) 2. Community Detection, i.e., the task of of finding groups of users (called communities) who frequently interact with each other but seldom with those outside their community (see section “Community Detection”) 3. Influential User Detection, i.e., the task of identifying users capable of stimulat- ing other users to join activities/discussions in their OSN (see section “Influential User Detection”). 294 S. Catanese et al.

Data Collection in OSN

The most works focusing on data collection adopt techniques of web information extraction [34], to crawl the front end of websites; this is because OSN datasets are usually not publicly accessible; data rests in back-end databases that are accessible only through the web interface. In [63] the problem of sampling from large graphs adopting several graph mining techniques, in order to establish whether it is possible to avoid bias in acquiring a subset of the whole graph of a social network is discussed. The main outcome of the analysis in [63] is that a sample of size of 15% of the whole graph preserves most of the properties. In [69], the authors crawled data from large online social networks like , Flickr, and LiveJournal. They carried out an in-depth analysis of OSN topological properties (e.g., link symmetry, power-law node degrees, groups formation) and discussed challenges arising from large-scale crawling of OSNs. Ye et al. [93] considered the problem of crawling OSNs analyzing quantitative aspects like the efficiency of the adopted visiting algorithms, and bias of data produced by different crawling approaches. The work by Gjoka et al. [42] on OSN graphs is perhaps the most similar to our current research, e.g., in [22]. Gjoka et al. have sampled and analyzed the Facebook friendship graph with different visiting algorithms namely, BFS, Random Walk, and Metropolis-Hastings Random Walks. Our objectives differ from those of Gjoka et al. because their goal is to produce a consistent sample of the Facebook graph. A sample is defined consistent when some of its key structural properties, i.e., node , assortativity and clustering coefficient approximate fairly well the corresponding properties of the original Facebook graph. Vice versa, our work aims at crawling a portion of the Facebook graph and to analytically study the structural properties of the crawled data. A further difference with [42] is in the strategy for selecting which nodes to visit: Gjoka’s strategy requires to know in advance the degree of the considered nodes. Nodes with the highest degree are selected and visited at each stage of the sampling. In the Facebook context, a node’s degree represents the number of friends a user has; such information is available in advance by querying the profile of the user. Such an assumption, however, is not applicable if we consider other online social networks. Hence, to know the degree of a node, we should preliminarily perform a complete visit of the graph, which may not be feasible for large-scale OSN graphs.

Similarity Detection

Finding similar users of a given OSN is a key issue in several research fields like Recommender Systems, especially Collaborative Filtering (CF) Recommender Systems [3]. In the context of social networks, the simplest way to compute user similarities is by means of accepted similarity metrics such as the well-known 12 Extraction and Analysis of Facebook Friendship Relations 295

Jaccard coefficient [50]. However, the usage of the Jaccard coefficient is often not satisfactory because it considers only the acquaintances of a user in a social network (and, therefore, local information) and does not take global information into account. A further drawback consists of the fact that users with a large number of acquaintances have a higher probability of sharing some of them w.r.t. users with a small number of acquaintances; therefore, they are likely to be regarded as similar even if no real similarity exists between them. Adamic and Adar [1] proposed that the similarity of two users increases if they share acquaintances who, in turn, have a low number of acquaintances themselves. In order to consider global network properties, many approaches rely on the idea of regular equivalence, i.e., on the idea that two users are similar if their acquaintances are similar too. In [13] the problem of computing user similarities is formalized as an optimization problem. Other approaches compute similarities by exploiting matrix-based methods. For instance, the approaches of [27, 61]use a modified version of the Katz coefficient, SimRank [53], provides an iterative fixpoint method. The approach of [14] operates on directed graphs and uses an iterative approach relying on their spectral properties. Some authors studied computational complexity of social network analysis with an emphasis on the problem of discovering links between social network users [85, 86]. To this purpose, tools like Formal Concept Analysis and Matrix Factorization are described and employed in this chapter. To describe these approaches, assume to consider a social network and let G D hV;Ei be the graph representing it; each node in V represents a user, whereas an edge specifies a tie between a pair of users (in particular, the fact that a user knows another user). In the first stage, Formal Concept Analysis is applied to map G onto a graph G0. The graph G0 is more compact than G (i.e., it contains less nodes and edges of G) but, however, it is sparse, i.e., a node in G0 still has few connections with other nodes. As a consequence, the task of predicting if two nodes are similar is quite hard and comparing the number of friends/acquaintances they share is not effective because, in most cases, two users do not share any common friend and, therefore, the similarity degree of an arbitrary pair of users will be close to 0. To alleviate sparsity, Singular Value Decomposition [46] (SVD) is applied. Experiments provided in [85] show that the usage of SVD is effective in producing a more detailed and refined analysis of social network data. The SVD is a technique from Linear Algebra which has been successfully em- ployed in many fields of computer science like Information Retrieval; in particular, given a matrix A,theSVD allows the matrix A to be decomposed as follows:

A D U†V; being U and V two orthogonal matrices (i.e., the columns of U and V are pairwise orthogonal); the matrix † is a diagonal matrix whose elements coincide with the square roots of the eigenvalues of the matrix AAT ; as usual, the symbol AT denotes the transpose of the matrix A. 296 S. Catanese et al.

The SVD allows to decompose a matrix A into the product of three matrices and if we would these three matrices, we would reconstruct the original matrix A. As a consequence, if A is the of a social network, any operation carried out on A can be equivalently performed on the three matrices U, †,andV in which A has been decomposed. The main advantage of such a transformation is that matrices U and V are dense and, then, we can compute the similarity degree of two users even if the number of friends they share is 0.

Community Detection

The problem of detecting groups of related nodes in a single social network has been largely analyzed in the physics, bioinformatics and computer science literature and is often known as community detection [71, 72] and studied, among others, by Borgatti et al. [18]. A number of community detection algorithms are based on the concept of network . In particular, if we assume that an OSN S (represented by means of a graph G) has been partitioned into m communities, the corresponding network modularity Q is defined as follows: Xm l2 d 2 Q D s s (12.1) L 2L sD1 where L is the number of edges in G, ls is the number of edges between nodes belonging to the sth community, and ds is the sum of the degrees of the nodes in the sth community. High values of Q reflect a high value of ls for each identified community; in turn, this implies that detected communities are highly cohesive and weakly coupled. Therefore, it is not surprising that the idea inspiring many community detection algorithms is to maximize the function Q. Unfortunately, maximizing Q is NP-hard [20], thus viable heuristics must be considered. A first heuristics is the Girvan-Newman algorithm (hereafter, GN) [41]. It relies on the concept of edge betweenness; in particular, given an edge e of S, its edge betweenness B.e/ is defined as

X X np .n ;n / B.e/ D e i l (12.2) np.ni ;nl / ni 2S nl 2S where ni and nl are nodes of S, np.ni ;nl / is the number of distinct shortest paths between ni and nl ,andnp e.ni ;nl / is the number of distinct shortest paths between ni and nl containing e itself. 12 Extraction and Analysis of Facebook Friendship Relations 297

Intuitively, edges with a high betweenness connect nodes belonging to different communities. As a consequence, their deletion would lead to an increase of Q. Algorithm GN relies on this intuition. It first ranks edges on the basis of their betweenness; then it removes the edge with the highest betweenness (Step 1). After this, it recomputes the betweenness of the remaining edges and the value of Q (Step 2). It repeats Steps 1 and 2 until it does not observe any significant increase of Q. At each iteration, each connected of S identifies a community. The computational complexity of GN is O.N3/, N being the number of nodes of S. The cubic complexity algorithm may not be scalable enough for the size of online social networks but a more efficient Ð O.N log2N/Ð implementation of GN can be found in [25]. Blondel et al. [15] propose to apply GN on the neighborhood of each node rather than on the whole network. Once communities have been identified, the group of nodes associated with a community is replaced by a supernode, thus producing a smaller graph. This process is iterated and, at each iteration, the function Q is recomputed. The algorithm ends when Q does not significantly increase anymore. Radicchi et al. [80] illustrate an algorithm which strongly resembles GN. In particular, for each edge e of S, it computes the so-called edge clustering coefficient of e, defined as the ratio of the number of cycles containing e to the maximum number of cycles which could potentially contain it. Next, GN is applied with the edge clustering coefficient (rather than edge betweenness) as the parameter of reference. The most important advantage of this approach is that the computational cost of the edge clustering coefficient is significantly smaller than that of edge betweenness. All approaches described above use the greedy technique to maximize Q. In [48], the authors propose a different approach which maximizes Q by means of the simulated annealing technique. That approach achieves a higher accuracy but can be computationally very expensive. Palla et al. [75] describes CFinder, which, to the best of our knowledge, is the first attempt to find overlapping communities, i.e., communities which may share some nodes. In CFinder, communities are detected by finding of size k,wherek is a parameter provided by the user. Such a problem is computationally expensive, but experiments showed that it scales well on real networks and it achieves a great accuracy. The approach of [73] uses a Bayesian probabilistic model to represent an online social network. An interesting feature of [73] is the capability of finding group structures, i.e., relationships among the users of a social network which go beyond those characterizing conventional communities. For instance, this approach is capable of detecting groups of users who show forms of aversion with each other rather than just users who are willing to interact. Experimental comparisons of various approaches to finding communities in OSNs are reported in [35, 65]. In [55], the authors propose CHRONICLE, an algorithm to find time-evolving communities in a social network. CHRONICLE operates in two stages: in the first one, it considers T “snapshots” of the social network in correspondence of T differ- ent timestamps. For each timestamp, it applies a density-based clustering algorithm 298 S. Catanese et al. on each snapshot to find communities in the social network. After this, it builds a T -partite graph GT which consists of T layers each containing the communities of nodes detected in the corresponding timestamp. It adds also some edges linking adjacent layers: they indicate that two communities, detected in correspondence of consecutive timestamps, share some similarities. As a consequence, the edges and the paths in GT identify similarities among communities over time.

Influential User Detection

A recent trend in OSN analysis is the identification of influential users [40, 74]. Influential users are those capable of stimulating others to join OSN activities and/or to actively contribute to them. In Weblog (blog) analysis, there is a special emphasis on so-called leader identification. In particular, Song et al. [87] suggested to model the blogosphere as a graph (whose nodes represent bloggers whereas edges model the fact that a blogger cites another one). In [66], the authors introduce the concept of starter, i.e., a user who first generates information that catches the interest of fellow users/readers. Among others, the approach of [66] has deployed the Random Walk technique to find starters. Researchers from HP Labs analyzed user behaviors on [82]; they found that influential users should not only catch attention from other users but they should also overcome the passivity of other users and spur them to get involved in OSN activities. To this purpose, they developed an algorithm (based on the HITS algorithm of [57]) to assess the degree of influence of a user. Experimental results show that high levels of popularity of a user do not necessarily imply high values in the degree of influence.

Sampling the Facebook

Our work on OSN analysis began with the goal to understand the organization of popular OSN, and as of 2010 Facebook was by far the largest and most studied. Facebook gathers more than 500 million active users, and its growth rate has been proved to be the highest among all the other competitors in the last few years. More than 50% of users log on to the platform in any given day. Coarse statistics about the usage of the social network is provided by the company itself.1 Our study is interested in analyzing the characteristics and the properties of this network on a large scale. In order to reach this goal, first of all we had to acquire data from this platform, and later we proceed to their analysis.

1Please refer to http://www.facebook.com/press/info.php?statistics 12 Extraction and Analysis of Facebook Friendship Relations 299

The Structure of the Social Network

The structure of the Facebook social network is simple. Each subscribed user can be connected to others via friendship relationships. The concept of friendship is bilateral, this means that users must confirm the relationships among them. Connections among users do not follow any particular hierarchy, thus we define the social network as unimodal. This network can be represented as a graph G D .V; E/ whose nodes V represent users and edges E represent friendship connections among them. Because of the assumption on the bilateralness of relationships, the graph is undirected. Moreover, the graph we consider is unweighted, because all the friendship connections have the same value within the network. However, it could be possible to assign a weight to each friendship relation, for instance, considering the frequency of interaction between each pair of users, or different criteria. Considering the assumption that loops are not allowed, we conclude that in our case it is possible to use a simple unweighted undirected graph to represent the Facebook social network. The adoption of this model has been proved to be optimal for several social networks (see [45]). Although choosing the model for representing a network could appear to be simple, this phase is important and could not be trivial. Compared to Facebook, the structure of other social networks requires a more complex representative model. For example, Twitter should be represented using a multiplex network; this is because it introduces different types of connections among users (“following,” “reply to” and “mention”) [83]. Similar considerations hold for other OSNs, such as aNobii [5], Flickr, and YouTube [69].

How to Get Information About the Structure of the Network

One important aspect to be considered for representing the model of a social network is the amount of information about its structure we have access to. The ideal condition would be to have access to the whole network data, for example acquiring them directly from the company which manages the social networking service. For several reasons (see further), most of the time this solution is not viable. Another option is to obtain data required to reconstruct the model of the network, acquiring them directly from the platform itself, exploiting its public interface. In other words, a viable solution is to collect a representative sample of the network to correctly represent its structure. To this purpose, it is possible to exploit web data mining techniques [34] to extract data from the front-end of the social network websites. This implies that, for very large OSNs, such as Facebook, Twitter, etc., it is hard or even impossible to collect a complete sample of the network. The first limitation is related to the computational overhead of a large-scale web mining task. In the case of Facebook, for example, to crawl the friend-list web page (dimension '200 KB) for the half billion users, it would approximately require to 300 S. Catanese et al. download more than 200 KB 500 M D 100 Tb of HTML data. Even if possible, the acquired sample would be a snapshot of the structure of the graph at the time of the mining process. Moreover, during the sampling process, the structure of the network slightly changes. This is because, even if short, the data mining process requires a nonnegligible time, during which the connections among users evolve, thus the social network, and its structure, changes accordingly. For example, the growth rate of Facebook has been estimated in the order of 0.2% per day [42]. In other words, neither all these efforts could ensure to acquire a perfect sample. For these reasons, a widely adopted approach is to collect small samples of a network, trying to preserve characteristics about its structure. There are several different sampling techniques that can be exploited; each algorithm ensures different performances, bias of data, etc. For our experimentation we collected two significant samples of the structure of the social network, of a size comparable to other similar studies [24, 42, 92]. In particular, we adopted two different sampling algorithms, namely, “breadth-first- search” and “Uniform.” The first is proved to introduce bias in certain conditions (e.g., in incomplete visits) toward high-degree nodes [59]. The latter is proved to be unbiased by construction [42]. Once collected, data are compared and analyzed in order to establish their quality, study their properties and characteristics. We consider two quality criteria to evalu- ate the samples: (1) coherency with statistical data provided by the social network itself; (2) congruency with results reported by similar studies. Considerations about the characteristics of both the “breadth-first-search” and the “Uniform” samples follow in section “Experimental Work.”

How to Extract Data from Facebook

Companies providing online social networking services, such as Facebook, Twitter, etc., do not have economic interests in sharing their data about users, because their business model mostly relies on advertising. For example, exploiting this informa- tion, Facebook provides unique and efficient services to advertising companies. Moreover, questions about the protection of these data have been advanced, for privacy reasons, in particular for Facebook [47, 67]. In this social network, for example, information about users and the interconnec- tions among them, their activities, etc. can only be accessed through the interface of the platform. To preserve this condition some constraints have been implemented. Among others, a limit is imposed to the amount of information accessible from profiles of users not in friendship relations among them. There are also some technical limitations, e.g., the friend list is dispatched through an asynchronous script, so as to prevent naive techniques of crawling. Some web services, such as the “Graph API,”2 have been provided during the last few months of 2010,

2Available from http://developers.facebook.com/docs/api 12 Extraction and Analysis of Facebook Friendship Relations 301

Fig. 12.1 Architecture of the data mining platform by the Facebook developers team, but they do not bypass these limitations (and they eventually add even more restrictions). As of 2010, the structure of this social network can be accessed only exploiting techniques typical of web data mining.

The Sampling Architecture

In order to collect data from the , we designed a web data mining architecture, which is composed of the following elements (see Fig. 12.1): (1) a server running the mining agent(s); (2) a cross-platform Java application, which implements the logic of the agent; and (3) an Apache interface, which manages the information transfer through the web. While running, the agent(s) query the Facebook server(s) obtaining the friend-list web pages of specific requested users (this aspect depends on the implemented sampling algorithm), reconstructing the structure of relationships among them. Collected data are stored on the server and, after a postprocessing step (see section “Data Preparation”), they are deli- vered (eventually represented using an XML standard format [21]) for further experimentation.

The Facebook Crawler

The cross-platform Java agent which crawls the Facebook front end is the core of our mining platform. The logic of the developed agent, regardless of the sampling algorithm implemented, is depicted in Fig. 12.2. The first preparative step for the agent execution includes choosing the sampling methodology and configuring some technical parameters, such as termination criterion/a, maximum running time, etc. Thus, the crawling task can start or be resumed from a previous point. During its execution, the crawler visits the friend-list page of a user, following the chosen sampling algorithm directives, for traversing the social graph. Data about new discovered nodes and connections among them are stored in a compact format, in order to save I/O operations. The process of crawling concludes when the termination criterion/a is/are met. 302 S. Catanese et al.

Fig. 12.2 State diagram of the data mining process

Table 12.1 HTTP requests flow of the crawler: authentication and mining steps Number Action Protocol Method URL KB 1 Open the Facebook page HTTP GET www.facebook.com/ 242 2 Login providing credentials HTTPS POST login.facebook.com/login.php 234 HTTP GET /home.php 87 3 Visit the friend-list page of a specific user HTTP GET /friends/ajax/friends.php?id=#&filter=afp 224

During the data mining step, the platform exploits the Apache HTTP Request Library3 to communicate with the Facebook server(s). After an authentication phase which uses a secure connection and “cookies” for logging into the Facebook platform, HTML friend-list web pages are obtained via HTTP requests. This process is described in Table 12.1.

Limitations

During the data mining task we noticed a technical limitation imposed by Facebook on the dimension of the dispatched friend-list web pages, via HTTP requests. To reduce the traffic through its network, Facebook provides shortened friend lists not exceeding 400 friends. During a normal experience of navigation on the website, if the dimension of the friend-list web page exceeds 400 friends, an asynchronous script fills the page with the remaining. This result is not reproducible using an agent based on HTTP requests. This problem can be avoided using a different mining approach, for example adopting visual data extraction techniques [34]. Data can be retrieved directly from the web page using specific scripts designed for a web browser, or alternatively by developing an agent which integrates a web browser for rendering the pages. This approach is not viable for large-scale mining tasks, but we already dealt with this approach in [22] for a smaller experimentation. In section “Degree Distribution,” we investigated the impact of this limitation on the samples.

3http://httpd.apache.org/apreq 12 Extraction and Analysis of Facebook Friendship Relations 303

Breadth-First-Search Sampling

The breadth-first-search (BFS) is an uninformed traversal algorithm which aims to visit a graph. Starting from a “seed node,” it explores its neighborhood; then, for each neighbor, it visits its unexplored neighbors, and so on, until the whole graph is visited (or, alternatively, if a termination criterion is met). This sampling technique shows several advantages: (1) ease of implementation; (2) optimal solution for unweighted graphs; (3) efficiency. For these reasons, it has been adopted in a variety of OSN mining studies, including [22,24,42,69,92,93]. In the last year, the hypothesis that the BFS algorithm produces biased data, toward high-degree nodes, if adopted for partial graph traversal, has been advanced by [59]. This is because, in the same (partial) graph, obtained adopting a BFS visiting algorithm, are both represented nodes which have been visited (high-degree nodes) and nodes which have just been discovered, as neighbors of visited ones (low-degree nodes). One important aspect of our experimentation has been to verify this hypothesis, in order to which properties of a partial graph obtained using the BFS sampling are preserved, and which are biased. To do so, we had to acquire a comparable sample which is certainly unbiased by construction (see further).

Description of the Breadth-First-Search Crawler

The BFS sampling methodology is implemented as one of the possible visiting algorithms in our Facebook crawler, described before. While using this algorithm, the crawler, for first, extracts the friend list of the “seed node,” which is represented by the user actually logged on to the Facebook platform. The user-IDs of contacts in its friend-list are stored in a FIFO queue. Then, the friend lists of these users are visited, and so on. In our experimentation, the process continued until two termination criteria have been met: (1) at least the third sublevel of friendship was completely covered; (2) the mining process exceeded 240 h of running time. As discussed before, the time constraint is adopted in order to observe a short mining interval; thus the temporal evolution of the network is minimal (in the order of 2%) and can be ignored. The obtained graph is a partial reconstruction of the Facebook network structure, and its dimension is used as a yardstick for configuring the “Uniform” sampling (see further).

Characteristics of the Breadth-First-Search Dataset

This crawler has been executed during the first part of August 2010. The acquired sample covers about 12 million friendship connections among about 8 million users. Among these users, we performed the complete visit of about 63.4 thousands of j j them, thus resulting in an average degree d D 2 E ' 396:4, considering V as the jVvj number of visited users. 304 S. Catanese et al.

Table 12.2 BFS dataset description (crawling period: 08/2001 to 10/2010) No. of visited users No. of discovered neighbors No. of edges 63.4K 8.21M 12.58M Avg. deg. Bigg. eigenval. Eff. diam. Avg. clust. coef. Coverage Density 396.8 68.93 8.75 0.0789 98.98% 0.626%

The overall mean degree, considering V as the number of total nodes on the j j graph (visited users C discovered neighbors), is o D 2 E ' 3:064. The expected jVt j j j density of the graph is D 2 E ' 0:006259 ' 0:626%, considering V jVvj.jVvj1/ as the number of visited nodes. We can combine the previous equations obtaining D d . It means that the expected density of a graph is the average proportion jVvj1 of edges incident with nodes in the graph. j j In our case, the value ı D o D Vv ' 0:007721 ' 0:772%, which here we d jVt j introduce, represents the effective density of the obtained graph. The among the effective and the expected density of the graph, which 100 here we introduce, is computed as @ D 100 ı ' 18:94%. This result means that the obtained graph is slightly more connected than expected, w.r.t. the number of unique users it contains. This consideration is also compatible with hypothesis advanced in [59]. The effective diameter of this (partial) graph is 8.75, which is compliant with the “six degrees of separation” theory [10, 68, 72, 88]. The coverage of the graph is almost complete (99.98%). The small amount of disconnected nodes can be intuitively adducted due to some collisions caused by the hash function exploited to de-duplicate and anonymize user-IDs adopted during the data cleaning step (see section “Data Preparation”). Some interesting considerations hold for the obtained clustering coefficient result. It lies in the lower part of the interval [0.05, 0.18] reported by [42] and, similarly, [0.05, 0.35] by [92], using the same sampling methodology. The characteristics of the collected sample are summarized in Table 12.2.

Uniform Sampling

To acquire a comparable sample, unbiased for construction, we exploited a rejection sampling methodology. This technique has been applied to Facebook in [42], where the authors proved its correctness. Its efficiency relies on the following assumptions: 1. It is possible to generate uniform sampling values for the domain of interest. 2. These values are not sparse w.r.t. the dimension of the domain. 3. It is possible to sample these values from the domain. 12 Extraction and Analysis of Facebook Friendship Relations 305

In Facebook, each user is identified by a 32-bit number user-ID. Considering that user-IDs lie in the interval [0, 232 1], the highest possible number of assignable user-IDs using this system is H ' 4:295e9. The space for names is currently filling up since the actual number of assigned user-IDs, R ' 5:4e8 roughly equals to the 540 million of currently subscribed users4;5, the two domains are comparable and the rejection sampling is viable. We generated an arbitrary number of random 32-bit user-IDs, querying Facebook for their existence (and, eventually, obtaining their friend lists). That sampling methodology shows two advantages: (1) we can statistically estimate the probability R H ' 12:5% of getting an existing user and (2) we can generate an arbitrary number of user-IDs in order to acquire a sample of the desired dimension. Moreover, the distribution of user-IDs is completely independent w.r.t. the graph structure.

Description of the “Uniform” Crawler

The “Uniform” sampling is another algorithm implemented in the Facebook crawler we developed. Differently w.r.t. the BFS sampler, if adopting this algorithm, it is possible to parallelize the process of extraction. This is because user-IDs to be requested can be stored in different “queues.” We designed the uniform sampling task starting from these assumptions: (1) the number of subscribed users is 229 ' 5:368e8; (2) this value is comparable with the highest possible assignable number of user-IDs, 232 ' 4:295e9, and (3) we can statistically assert that the possibility of 229 1 querying Facebook for an existing user-ID is 232 D 8 .12:5%/. For this purpose, we generated eight different queues, each containing 216 ' 65:5K Š 63:4K random user-IDs (the number of visited users of the BFS sample), used to feed eight parallel crawlers.

Characteristics of the “Uniform” Dataset

The uniform sampling process has been executed during the second part of August 2010. The crawler collected a sample which contains almost eight million friendship connections among a similar number of users. The acquired amount of nodes differs from the expected number due to the privacy policy adopted by those users who prevent their friend-lists being visited. The privacy policy aspect is discussed in section “Privacy Settings.” The total number of visited users has been about 48.1 thousand, thus resulting in j j an average degree of d D 2 E ' 326:0, considering V as the number of visited jVvj j j users. Same assumptions, the expected density of the graph is D 2 E ' jVvj.jVvj1/ 0:006777 ' 0:678%.

4As of August 2010, http://www.facebook.com/press/info.php?statistics 5http://www.google.com/adplanner/static/top1000/ 306 S. Catanese et al.

If we consider V as the number of total nodes (visited users C discovered j j neighbors), the overall mean degree is o D 2 E ' 2:025. The effective density of jVt j j j the graph, previously introduced, is ı D Vv ' 0:006214 ' 0:621%. The distance jVt j 100 among the effective and the expected density of the graph, is @ D 100 ı ' 9:06%. This can be intuitively interpreted as a slight lack of connection of this sample w.r.t. the theoretical expectation. Some considerations hold, also comparing against the BFS sample: the average degree is slightly less (326.0 vs. 396.8), but the effective diameter is almost the double (16.32 vs. 8.75). We justify this characteristic considering that the sample could be still too small and disconnected to perfectly reflect the structure of the network. Our hypothesis is also supported by the dimension of the largest connected component, which does not contain the 5% of the sample. Finally, the clustering coefficient, less than the BFS sample (0.0471 vs. 0.0789), is still comparable w.r.t. previously considered studies [42, 92].

Data Preparation

During the data mining process, it could happen to store redundant information. In particular, while extracting friend-lists, a crawler could save multiple instances of the same edge (i.e., a parallel edge), if both the connected users are visited; this is because the graph is undirected. We adopted a hashing-based algorithm which cleans data in O.N/ time, removing duplicate edges. Another step, during the data preparation, is the anonymization: user-IDs are “encrypted” adopting a 48-bit hybrid rotative and additive hash function [77], to obtain anonymized datasets. The final touch was to verify the integrity and the congruency of data. We found that the usage of the hashing function caused occasional collisions (0.0002%). Finally, some datasets of small sub-graphs (e.g., ego-networks) have been postprocessed and stored using the GraphML format [21].

Network Analysis Aspects

During the last years, important achievements have been reached in understanding the structural properties of several complex real networks. The availability of large-scale empirical data, on the one hand, and the advances in computational resources, on the other, made it possible to discover and understand interesting statistical properties commonly shared among different real-world social, biological and technological networks. Among others, some important examples are: the World Wide web [6], Internet [32], metabolic networks [54], scientific collaboration networks [11,70], citation networks [81], etc. Indeed, during the last years, even the social networks are strongly imposing themselves as complex networks described by very specific models and properties. For example, some studies [8,68,88] proved the existence of the so-called “small-world” property in complex social networks. 12 Extraction and Analysis of Facebook Friendship Relations 307

Others [2, 76] assert that the so-called “scale-free” complex networks reflect a “power-law” distribution as model for describing the behavior of node degrees. We can conclude that the topology of the networks usually provides useful information about the dynamics of the network entities and the interaction among them. In addition to contributing to the advances in graph theory, the study of complex networks led to important results also in some specific contexts, such as the social sciences. A branch of the network analysis applied to social sciences is the Social Network Analysis (SNA). From a different perspective w.r.t. the analysis of complex networks, which mainly aims to analyze structural properties of networks, the SNA focuses on studying the nature of relationships among entities of the network and, in the case of social networks, investigating the motivational aspect of these connections. In this section, we will briefly describe properties and models characterizing the structure of complex networks (see sections “Definitions” and “Networks Models”); then we will focus on defining measures and metrics property of SNA (see section “Social Network Analysis”) and, while concluding, we will consider some interesting aspects regarding the visualization of related graphs (see section “Visualizing Social Networks”).

Definitions

In this section, we describe some of the common structural properties which are usually observed in several complex networks and define the way they are measured. Then, we describe concepts about the mathematical modeling of networks, includ- ing models and their generalizations, the “small-world” model and its variations, and models of growth and evolution of graphs, including the models.

Shortest Lengths, Diameter, and Betweenness

Let G D .V; E/ be a graph representing a network; the distance dij between two nodes, labeled i and j , respectively, is defined as the number of edges along the shortest path connecting them. The diameter D of the network represented by G, therefore, is defined to be the maximal distance among all distances between any pair of nodes in the network. A common measure of distance between two nodes of the graph G,isgivenby the average shortest path length [90, 91] (also called characteristic path length), defined as the mean value of the geodesic distance (i.e., the shortest path) between the all-pairs node of the graph (a.k.a. the “all-pairs-shortest-path problem” [84]): 1 X ` D d (12.3) N.N 1/ ij i¤j 308 S. Catanese et al.

The main problem adopting this definition is that ` diverges if the graph contains disconnected components. A possible solution to this issue is to limit the domain of the summation in Eq. 12.3 only to the pairs of nodes belonging to the largest connected component of the graph. Several metrics have been defined to compute the of a node within a graph, such as the degree, closeness, and the betweenness centrality. The latter one has been originally introduced to quantitatively evaluate the importance of an individual in a network [60,89] and is recognized to be the most appropriate measure to reflect the concept of centrality in a network. The betweenness centrality of a node was defined by Freeman [36,37]asinEq.12.2. Correlations “betweenness-vs.- betweenness” and “betweenness-vs.-degree” have been investigated, respectively, by authors of Refs. [43]and[26, 44, 49]. In section “Betweenness Centrality in Facebook,” we will focus on analyzing this metric calculated on the Facebook graph, for reasons further explained.

Clustering

In several networks, it is shown that if a node i is connected to a node j , which in its turn is connected to a node k, then there is a heightened probability that node i will be also connected to node k. From a social network perspective, a friend of your friend is likely also to be your friend. In terms of , transitivity means the presence of a heightened number of triangles in the network, which constitute sets of three nodes connected to each other [71]. The global clustering coefficient is defined by

3 no: of triangles in G C D (12.4) g no: of connected triples where a connected triple represents a pair of nodes connected to another node. Cg is the mean probability that two persons who have a common friend are also friends together. An alternative definition of clustering coefficient C has been provided by Watts and Strogatz [91]. During our experimentation, we investigated the clustering effect on the Facebook network (see section “Diameter and Clustering Coefficient”).

The “Small-World” Property

It is well known in literature that most large-scale networks, despite their huge size, show a common property: there exists a relatively short path which connects any pair of nodes within the network. This characteristic, the so-called small-world property, is theoretically supported by the average shortest path length, defined by Eq. 12.3, and it scales proportionally to the logarithm of the dimension of the network. The study of this phenomenon is rooted in social sciences [68, 88]and 12 Extraction and Analysis of Facebook Friendship Relations 309 is strictly interconnected with the notion of diameter we introduced before. The Facebook social network reflects the “small-world” property as discussed in section “Diameter and Clustering Coefficient.”

Scale-Free Degree Distributions

On the one hand, in a random graph (see further), the node degree (i.e., the number of edges the node has) is characterized by a distribution function P.k/ which defines the probability that a randomly chosen node has exactly k edges. Because the distribution of edges in a random graph is aleatory, most of the nodes have approximately the same node degree, similar to the mean degree hki of the network. Thus, the degree distribution of a random graph is well described by a Poisson distribution law, with a peak in P.hki/. On the other hand, recent empirical results show that in most of the real-world networks the degree distribution significantly differs w.r.t. a Poisson distribution. In particular, for several large-scale networks, such as the World Wide web [6], Internet [32], metabolic networks [54], etc., the degree distribution follows a power law:

P.k/ k (12.5)

This power-law distribution falls off more gradually than an exponential one, allowing for a few nodes of very large degree to exist. Since these power laws are free of any characteristic scale, such a network with a power-law degree distribution is called a scale-free network [9]. We proved that Facebook is a scale-free network well described by a power-law degree distribution, as discussed in section “Degree Distribution.”

Network Models

Concepts such as the short path length, the clustering, and the scale-free degree distribution have been recently applied to rigorously model the networks. Three main modeling paradigms exist: (1) random graphs, (2) “small-world” networks, and (3) power-law networks. Random graphs represent an evolution of the Erdos-˝ Renyi« model, and are widely used in several empirical studies, because of the ease of adoption. After the discovery of the clustering property, a new class of models, namely, “small-world” networks, has been introduced. Similarly, the power- law degree distribution definition led to the modeling of the homonym networks, which are adopted to describe scale-free behaviors, focusing on the dynamics of the network in order to explain phenomena such as the power-law tails and other non-Poisson degree distribution, empirically shown by real-world networks. 310 S. Catanese et al.

The Erdos-R˝ enyi´ Model

Erdos˝ and Renyi« [30, 31] proposed one of the first models of network, the random graph. They defined two models: the simple one consists of a graph containing n vertices connected randomly. The commonly adopted model, indeed, is defined as agraphGn;p in which each possible edge between two vertices may be included in the graph with the probability p (and may not be included with the probability (1 p)). Although random graphs have been widely adopted because their properties ease the work of modeling networks (e.g., random graphs have a small diameter), they do not properly reflect the structure of real-world large-scale networks, mainly for two reasons: (1) the degree distribution of random graphs follows a Poisson law, which substantially differs from the power-law distribution shown by empirical data; (2) they do not reflect the clustering phenomenon, considering all the nodes of the network with the same “weight,” and reducing, de facto, the network to a giant cluster.

The Watts-Strogatz Model

The real-world social networks are well connected and have a short average path length like random graphs, but they also have exceptionally large clustering coefficient, which is not reflected by the Erdos-R˝ enyi« model or by other random graph models. In [91], Watts and Strogatz proposed a one-parameter model that interpolates between an ordered finite dimensional lattice and a random graph. Starting from a ring lattice with n vertices and k edges per , each edge is rewired at random with probability p [91]. The model has been widely studied since the details have been published. Its role is important in the study of the small-world theory. Some relevant theories, such as Kleinberg’s work [56, 57], are based on this model and its variants. The disadvantage of the model, however, is that it is not able to capture the power-law degree distribution as presented in most real-world social networks.

The Barabasi-Albert´ Model

The two previously discussed theories observe properties of real-world networks and attempt to create models that incorporate those characteristics. However, they do not help in understanding the origin of social networks and how those properties evolve. The Barabasi-Albert« model suggests that two main ingredients of self- organization of a network in a scale-free structure are growth and preferential attachment. These pinpoint to the facts that most of the networks continuously grow by the addition of new nodes which are preferentially attached to existing 12 Extraction and Analysis of Facebook Friendship Relations 311 nodes with large numbers of connections (again, “rich gets richer”). The generation scheme of a Barabasi-Albert« scale-free model is as follows: (1) Growth:letpk be theP fraction of nodes in the undirected network of size n with degreeP k,so 1 that k pk D 1 and therefore the mean degree m of the network is 2 k kpk. Starting with a small number of nodes, at each time step, we add a new node with m edges linkedQ to nodes already part of the system; (2) preferential attachment: the probability i that a new node will be connected to the node i (one of the m Qalready existingP nodes) depends on the degree ki of the node i,insuchawaythat i D ki j kj . Models based on preferential attachment operates in the following way. Nodes are added one at a time. When a new node u has to be added to the network, it creates m edges (m is a parameter and it is constant for all nodes). The edges are not placed uniformly at random but preferentially, i.e., probability that a new edge of u is placed to a node v of degree d.v/ is proportional to its degree, pu.v/ / d.v/.This simple behavior leads to power-law degree tails with exponent D 3. Moreover, it also leads to low diameters. While the model captures the power-law tail of the degree distribution, it has other properties that may or may not agree with empirical results in real networks. Recent analytical research on average path length indicates that ` ln.N/=lnln.N/. Thus the model has much shorter l w.r.t. a random graph. The clustering coefficient decreases with the network size, following approximately apower-lawC N 0:75. Though greater than those of random graphs, it depends on network size, which is not true for real-world social networks.

Social Network Analysis

In the previous section, we discussed about the network as a complex system: in particular, complex , by its graph theoretical approach, does not explain the network by its elements’ behavior, but it deals with a whole organism that evolves by means of its single components. In this section, instead, we approach the study of that components: SNA deals with the study of the actors involved in a network. It is an approach based on the analysis of the behavior of single entities which are part of the network and govern its evolution. The single components have the possibility of choosing their own connections without considering the network as a whole structure but only w.r.t. individual characteristics. Indeed, almost the totality of social network models deals with the external information on the actors. Social network analysts often use these additional information to explain network formation. This is the principal difference between social network analysis and theory. In the latter, we often disregard the additional information on the single nodes because the attention is pointed out toward a more structural method, namely, a systemic approach. 312 S. Catanese et al.

Metrics

Metrics allow analysts to systematically dissect the social world, creating a basis on which to compare networks, track changes over the time, and determine the relative position of individuals and clusters within the network [51]. One of the primary uses of graph theory in social network analysis is the identification of the most important actors in a social network [89]. The degree centrality is a measure of the degree of an actor in a network. An actor with a high- degree centrality is “where the action is” in the network. Thus, this measure focuses on the most visible actors in the network. This actor can be recognized by others as a major channel of relational information. In contrast, actors with low degrees are peripheral in the network. A second view of centrality is based on closeness or distance. This measure focuses on how close an actor is to all the other actors in the network. This idea of centrality based on closeness is inversely related to the distance. As a node grows farther apart in distance from other nodes, its centrality will decrease, since there will be more lines in the geodesics linking that node to the rest [33]. Finally, interactions between two non-adjacent actors might depend on the other actors, especially those lying on the paths between them. These other actors potentially might have some control over the interactions between the two nonadjacent actors. The important idea here is that an actor is central if it lies between other actors on their geodesics. This implies that to have a large betweenness centrality [36], the actor must be between many of the actors via their geodesics [91]. Although this centrality has gained popularity because of its generality, this index assumes that all geodesics are equally likely when estimating the critical probability that an actor fall on a particular geodesic. It also ignores the fact that if some actors on the geodesics have large degrees, then the geodesics containing these expansive actors are more likely to be used as shortest paths than other geodesics. Also it would be more realistic to consider betweenness counts which focus on paths other than geodesics. Information centrality generalizes the notion of betweenness centrality, so all paths between actors, with weights depending on their lengths, are considered when calculating the betweenness counts.

Visualizing Social Networks

One of the key elements that characterize modern social network analysis is the visual representation. Looking at a network graph may provide an overview of the structure of the network, calling out cliques, communities, and key participants. Drawings of relational structures like social networks are only useful if they “effectively convey information to the people that use them” [19, 28, 29]. Network visualization is often as frustrating as appealing. Network graphs can rapidly get too dense and large to make out any meaningful patterns. Many obstacles like vertex occlusions and edge crossings make creating well-organized and readable network 12 Extraction and Analysis of Facebook Friendship Relations 313

Fig. 12.3 N-Body approach with LogAnalysis graphs challenging. There is an upper limit on the number of vertices and edges that can be displayed in a bounded set of pixels; typically, only a few hundred or thousand vertices can be meaningfully and distinctly represented on average-sized computer screens. A key reference for better-quality network visualization is the so-called Netviz Nirvana guidelines [79]. Several graph layout algorithms can be used, including variants of the “spring embedder” such as the Harel-Koren [52] fast multi-scale method, the popular Fruchterman-Reingold [38] force-directed algorithm, and more scalable gravitational N-Body approaches (see Figs. 12.3 and 12.4), such as those implemented in LogAnalysis [23]andNodeXL [51]. The results of applying these algorithms vary depending on the size and topology of the network. LogAnalysis presents social networks using a familiar node-link representation, where nodes represent members of the system and links represent the articulated “friendship” links between them. It integrates statistics proposed by Perer and Shneiderman [78]: overall network metrics (i.e., number of nodes, number of edges, density, diameter), node rankings (i.e., degree, betweenness and closeness centrality), edge rankings (i.e., weight, betweenness centrality), edge rankings in pairs, and cohesive subgroups. Network members are presented using both their self-provided name, ID (e.g., the Facebook user-ID) and, if available, a representative photograph (e.g., the Facebook profile picture). The networks are presented as egocentric networks. Users can expand the display by selecting nodes to make visible others’ friends as well. Analysts can also explore a network by focusing on one node, the node’s neighbors, and the ties among them and can interactively increase the depth of the neighborhood by dragging a slider bar. 314 S. Catanese et al.

Fig. 12.4 Betweenness centrality and clustering effect in an ego-network of 25K nodes

Betweenness Centrality in Facebook

The analysis of large ego-networks led us to another interesting consideration on the behavior of the betweenness centrality (BC); it goes as follows. Clearly, the more a node is central and important, the higher its BC. One could suppose that this measure is directly interconnected with the degree of a node, or with other measures of centrality (e.g., the Pagerank). In Fig. 12.4, we show the behavior of this metric evaluated on an ego-network of about 25,000 of nodes. The following consideration holds: the node which covers the most important position in this network (vertex “8478,” in red) does not show “special” properties (e.g., its degree and its Pagerank are lower than most of the other nodes). However, it appears in more than the double of shortest paths w.r.t. the other nodes of the network. Similar considerations hold for other nodes (vertices “24221,” “5851,” “9453,” in yellow, and “11661,” “24853,” in green) in this particular ranking. Intuitively, nodes with high BC represent a potential efficient way of connection among peripheral nodes. It is known that the BC distribution follows a power law p.g/ g for scale-free networks [43]. Similarly to the degree exponent case, in general, the BC exponents increase for node and link sampling and decrease for snowball sampling as the sampling fraction gets lower. The correlation between degree and BC of nodes [12], shown in Fig. 12.10 (section “Connected Components”), could explain the same direction of changes of degree and BC exponents. We can conclude that the study of the betweenness centrality in Facebook is fundamental for all those aspects related to discovering central nodes of the network, and that BC is a numerical property for applications (e.g., for marketing purposes, broadcasting news, etc.). 12 Extraction and Analysis of Facebook Friendship Relations 315

Experimental Work

We describe some interesting experimental results as follows. To compute the community profile of a network and its node centrality measures, such as degree and betweenness, we have adopted the Stanford Network Analysis Platform (SNAP) [62], a general-purpose network analysis library.

Privacy Settings

We investigated the adoption of restrictive privacy policies by users: our statistical 216 expectation using the “Uniform” crawler was to acquire 8 23 ' 65:5Kusers. Instead, the actual number of collected users was 48.1K. Because of privacy settings chosen by users, the discrepancy between the expected number of acquired users and the actual number was about 26.6%. In other words, only a quarter of Facebook users adopt privacy policies which prevent other users (except for those in their friendship network) from visiting their friend-list.

Degree Distribution

A first description of the network topology of the Facebook friendship graph can be obtained from the degree distribution. According to Eq. 12.5, a relatively small number of nodes exhibit a very large number of links. An alternative approach involves the Complementary Cumulative Distribution Function (CCDF)

Z 1 }.k/ D P.k0/dk0 k˛ k.1/ (12.6) k

When calculated for a , CCDF shows up as a straight line in a log-log plot, while the exponent of the power-law distribution only varies the height (not the shape) of the curve. In Fig. 12.5 is plotted the degree distribution, as obtained from the BFS and “Uniform” sampling techniques. The limitations due to the dimensions of the cache which contains the friend-lists, upper bounded to 400, are evident. The BFS sample introduces an overestimate of the degree distribution in the left and the right part of the curves. The CCDF is shown, for the same sample, in Fig. 12.6.

Diameter and Clustering Coefficient

It is well known that most real-world graphs exhibit a relatively small diameter. A graph has diameter D if every pair of nodes can be connected by a path of length 316 S. Catanese et al.

Fig. 12.5 Degree distribution

Fig. 12.6 CCDF degree distribution of at most D edges. The diameter D may be affected by outliers (again, the small- world phenomenon). A robust measure of the pairwise distances between nodes in a graph is the effective diameter, which is the minimum number of links (steps/hops) within which some fraction (or quantile q, say q D 0:9) of all connected pairs of nodes can reach each other. The effective diameter has been found to be small for large real-world graphs, like Internet and the web, real-life and OSNs [7, 64, 68]. The hop-plot package extends the notion of diameter by plotting the number of reachable pairs g.h/ within h hops, as a function of the number of hops h [76]. 12 Extraction and Analysis of Facebook Friendship Relations 317

Fig. 12.7 Hops and diameter

It gives us a sense of how quickly the neighborhoods of nodes expand with the number of hops. In Fig. 12.7, the number of hops necessary to connect any pair of nodes is plotted as a function of the number of pairs of nodes. As a consequence of the more “compact” structure of the graph, the BFS sample shows a faster convergence to the asymptotic value listed in Table 12.2. The clustering coefficient of a node is the ratio of the number of existing links over the number of possible links between its neighbors. Given a network G D .V; E/, a clustering coefficient, Ci , of node i 2 V is:

Ci D 2jf.v; w/j.i; v/; .i; w/; .v; w/ 2 Egj=ki .ki 1/ (12.7) where ki is the degree of node i. It can be interpreted as the probability that any two nodes that share a common neighbor have a link between them. The clustering coefficient of a node represents how well connected its neighbors are. For any node in a tightly connected mesh network, the clustering coefficient is 1. The clustering coefficient of a network is the mean clustering coefficient of all nodes. Often, it is insightful to examine not only the mean clustering coefficient (see section “Clustering”), but its distribution. In Fig. 12.4, it is possible to clearly identify the clustering effect of a Facebook subgraph, visually enhanced by applying several iterations of the Fruchterman-Reingold algorithm [38]. Figure 12.8 shows the average clustering coefficient plotted as a function of the node degree for the two sampling techniques. As a consequence of the more systematic approach of extraction, the distribution of the clustering coefficient of the BFS sample shows a smooth behavior. 318 S. Catanese et al.

Fig. 12.8 Clustering coefficient

Table 12.3 “Uniform” dataset description (crawling period: 08/2011 to 20/2010) No. of visited users No. of discovered neighbors No. of edges 48.1K 7.69M 7.84M Avg. deg. Bigg. eigenval. Eff. diam. Avg. clust. coef. Coverage Density 326.0 23.63 16.32 0.0471 94.96% 0.678 %

The following considerations hold for the diameter and hops: the BFS sample may be affected by the “wavefront expansion” behavior of the visiting algorithm, while the “Uniform” sample may still be too small to represent a faithful estimate of the diameter (this hypothesis is supported by the dimension of the largest connected component which does not cover the whole graph, as discussed in the next paragraph). Different conclusions can be derived for the clustering coefficient property. It is important to observe that the average values of the two samples fluctuate in the same interval reported by recent similar studies on OSNs (i.e., [0.05, 0.18] by Wilson et al. [92], [0.05, 0.35] by Gjoka et al. [42]), thus confirming that this property is preserved by both the adopted sampling techniques.

Connected Components

A connected component is a maximal set of nodes where for each pair of nodes there exists a path connecting them. Analogously, directed graphs show weakly and strongly connected components. As shown in Tables 12.2 and 12.3, the largest connected components cover the 99.98% of the BFS graph and the 94.96% of the “Uniform” graph. In Fig. 12.9, 12 Extraction and Analysis of Facebook Friendship Relations 319

Fig. 12.9 Connected components

the scattered points in the left part of the plot have a different meaning for each sampling techniques. In the “Uniform” case, the sampling picked up disconnected nodes. In the BFS case, disconnected nodes are meaningless, as they are due to some collisions of the hashing function during the de-duplication phase of the data- cleaning step. This interpretation is supported by their small number (29 collisions over 12.58 millions of hashed edges) involving only 0.02% of the total edges. However, the quality of the sample is not affected. These conclusions are confirmed in Fig. 12.10, where the betweenness centrality is plotted as a function of the degree. In the right part of the plot, the betweenness centrality shows a linearly proportional behavior w.r.t. the degree. In our opinion, this implies a high degree of connectedness of the sample, since a high value of betweenness centrality is related to a high value of the degree of the nodes.

Conclusions

The success of OSNs and the growth of their user base is of great interest to both social and computer science. Extraction and analysis of OSN data describing social networks pose both a technological challenge and an interpretation challenge. We have presented here our long-term research project on social network analysis and our two implemented systems: the ad hoc Facebook crawler and the LogAnalysis tool for analysis and visualization. The ad hoc Facebook crawler has been developed to comply with the increasingly strict terms of Facebook end-user license, i.e., to create large, fully anonymous 320 S. Catanese et al.

Fig. 12.10 Betweenness centrality vs degree (on an ego-network of 25K nodes) samples that can be employed for scientific purposes. Two different sampling techniques have been implemented in order to explore the graph of friendships of Facebook, since the BFS visiting algorithm is known to introduce a bias in case of an incomplete visit. Analysis of such large samples was tackled using concepts and algorithms typical of the graph theory, namely, users were represented by nodes of a graph and relations among users were represented by edges. Our LogAnalysis tools support OSN analysis and give a graphical visualization of key graph theory and social net- work analysis concepts: degree distribution, diameter, centrality metrics, clustering coefficient computation, and eigenvalues distribution. Future developments involve the implementation of different sampling techniques (e.g., Monte Carlo Random Walks) in order to speed up the data extraction process and the evaluation of network metrics.

Acknowledgements We appreciated the encouragement and comments of Robert Baumgartner, Georg Gottlob, Christian Schallhart, and Domenico Ursino.

References

1. Adamic, L., Adar, E.: Friends and neighbors on the web. Soc. Netw. 25(3), 211Ð230 (2003) 2. Adamic, L., et al.: Power-law distribution of the world wide web. Science 287(5461), 2115 (2000) 3. Adomavicius, G., Tuzhilin, A.: Toward the next generation of recommender systems: a survey of the state-of-the-art and possible extensions. IEEE Trans. Knowl. Data Eng. 17(6), 734Ð749 (2005) 12 Extraction and Analysis of Facebook Friendship Relations 321

4. Ahn, Y., Han, S., Kwak, H., Moon, S., Jeong, H.: Analysis of topological characteristics of huge online social networking services. In: Proceedings of the 16th International Conference on the World Wide Web, pp. 835Ð844. ACM, Banff, AB, Canada (2007) 5. Aiello, L.M., Barrat, A., Cattuto, C., Ruffo, G., Schifanella, R.: Link creation and profile alignment in the aNobii social network. In: Proceedings of the 2nd IEEE International Conference on Social Computing, pp. 249Ð256. Minneapolis, MN, USA (2010) 6. Albert, R.: Diameter of the world wide web. Nature 401(6749), 130 (1999) 7. Albert, R., Barabasi,« A.: Statistical mechanics of complex networks. Rev. Mod. Phys. 74(1), 47Ð97 (2002) 8. Amaral, L., Scala, A., Barthel« emy,« M., Stanley, H.: Classes of small-world networks. Proc. Natl. Acad. Sci. 97(21), 11149 (2000) 9. Barabasi,« A., Albert, R.: Emergence of scaling in random networks. Science 286(5439), 509 (1999) 10. Barabasi,« A., Crandall, R.: Linked: the new science of networks. Am. J. Phys. 71, 409 (2003) 11. Barabasi,« A., Jeong, H., Neda,« Z., Ravasz, E., Schubert, A., Vicsek, T.: Evolution of the social network of scientific collaborations. Phy. A Stat. Mech. Appl. 311(3Ð4), 590Ð614 (2002) 12. Barthelemy, M.: Betweenness centrality in large complex networks. Eur. Phys. J. B 38, 163Ð168 (2004) 13. Batagelj, V., Doreian, P., Ferligoj, A.: An optimizational approach to regular equivalence. Soc. Netw. 14(1Ð2), 121Ð135 (1992) 14. Blondel, V., Gajardo, A., Heymans, M., Senellart, P., van Dooren, P.: A measure of similarity between graph vertices: applications to synonym extraction and web searching. SIAM Rev. 46(4), 647Ð666 (2004) 15. Blondel, V., Guillaume, J., Lambiotte, R., Lefebvre, E.: Fast unfolding of communities in large networks. J. Stat. Mech. 10, P10008 (2008) 16. Boldi, P., Rosa, M., Santini, M., Vigna, S.: Layered label propagation: a multiresolution coordinate-free ordering for compressing social networks. In: Proceedings of the 20th International Conference on World Wide Web. ACM Press, Hyderabad, India (2011) 17. Boldi, P., Vigna, S.: The WebGraph framework I: compression techniques. In: Proceedings of the 13th International World Wide Web Conference, pp. 595Ð601. ACM Press, New York, NY, USA (2004) 18. Borgatti, S.P., Everett, M.G.: Models of core/periphery structures. Soc. Netw. 21(4), 375Ð395 (2000) 19. Boyer, J.M., Myrvold, W.J.: On the cutting edge: simplified on planarity by edge addition. J. Graph Algorithms Appl. 8(3), 241Ð273 (2004) 20. Brandes, U., Delling, D., Gaertler, M., Gorke, R., Hoefer, M., Nikoloski, Z., Wagner, D.: On modularity clustering. IEEE Trans. Knowl. Data Eng. 20(2), 172Ð188 (2008) 21. Brandes, U., Eiglsperger, M., Herman, I., Himsolt, M., Marshall, M.: GraphML progress report structural layer proposal. In: , pp. 109Ð112. Berlin, Springer (2002) 22. Catanese, S., De Meo, P., Ferrara, E., Fiumara, G.: Analyzing the facebook friendship graph. In: Proceedings of the 1st International Workshop on Mining the Future Internet, pp. 14Ð19. Berlin, Germany (2010) 23. Catanese, S., Fiumara, G.: A visual tool for forensic analysis of mobile phone traffic. In: Proceedings of the 2nd ACM Workshop on Multimedia in Forensics, pp. 71Ð76. ACM, Florence, Italy (2010) 24. Chau, D., Pandit, S., Wang, S., Faloutsos, C.: Parallel crawling for online social networks. In: Proceedings of the 16th International Conference on the World Wide Web, pp. 1283Ð1284. Banff, AB, Canada (2007) 25. Clauset, A., Newman, M., Moore, C.: Finding in very large networks. Phys. Rev. E 70(6), 066111 (2004) 26. Crucitti, P., Latora, V., Marchiori, M.: A topological analysis of the Italian electric power grid. Phys. A 338, 92Ð97 (2004) 27. De Meo, P., Ferrara, E., Fiumara, G.: Finding similar users in facebook. In: Social Networking and Community Behavior Modeling. IGI Publisher, Hershey, Pennsylvania, USA (2011) 322 S. Catanese et al.

28. Di Battista, G., Eades, P., Tamassia, R., Tollis, I.: Algorithms for drawing graphs: an annotated bibliography. Comput. Geom. 4(5), 235Ð282 (1994) 29. Di Battista, G., Eades, P., Tamassia, R., Tollis, I.: Graph Drawing: Algorithms for the Visualization of Graphs. Prentice Hall, Upper Saddle River (1998) 30. Erdos,˝ P., Renyi,« A.: On random graphs. Pub. Math. 6(26), 290Ð297 (1959) 31. Erdos,˝ P., Renyi,« A.: On the evolution of random graphs. In: Publication of the Mathematical Institute of the Hungarian Academy of Sciences (1960) 32. Faloutsos, M., Faloutsos, P., Faloutsos, C.: On power-law relationships of the internet topology. In: ACM SIGCOMM Computer Communication Review, vol. 29, pp. 251Ð262. ACM, New York (1999) 33. Faust, K., Wasserman, S.: Centrality and prestige: a review and synthesis. J. Quant. Anthr. 4(1985), 23Ð78 (1992) 34. Ferrara, E., Fiumara, G., Baumgartner, R.: Web data extraction, applications and techniques: a survey. Techinical Report (2010) 35. Fortunato, S.: Community detection in graphs. Phys. Rep. 486, 75Ð174 (2010) 36. Freeman, L.: A set of measures of centrality based on betweenness. Sociometry 40(1), 35Ð41 (1977) 37. Freeman, L.: Centrality in social networks conceptual clarification. Soc. Netw. 1(3), 215Ð239 (1979) 38. Fruchterman, T., Reingold, E.: Graph drawing by force-directed placement. Softw. Pract. Exp. 21(11), 1129Ð1164 (1991) 39. Garton, L., Haythornthwaite, C., Wellman, B.: Studying online social networks. J. Comput. Med. Commun. 3(1), 75Ð105 (1997) 40. Ghosh, R., Lerman, K.: Predicting influential users in online social networks. In: Proceedings of KDD Workshop on Social Network Analysis (SNA-KDD). Washington, DC, USA (2010) 41. Girvan, M., Newman, M.E.: Community structure in social and biological networks. Proc. Nat. Acad. Sci. 99(12), 7821Ð7826 (2002) 42. Gjoka, M., Kurant, M., Butts, C., Markopoulou, A.: Walking in Facebook: a case study of unbiased sampling of OSNs. In: Proceedings of the 29th Conference on Information Communications, pp. 2498Ð2506. IEEE, San Diego, CA, USA (2010) 43. Goh, K., Kahng, B., Kim, D.: Universal behavior of load distribution in scale-free networks. Phys. Rev. Lett. 87(27), 278701 (2001) 44. Goh, K., Oh, E., Kahng, B., Kim, D.: Betweenness centrality correlation in social networks. Phys. Rev. E 67(1), 17,101 (2003) 45. Goldenberg, A., Zheng, A., Fienberg, S., Airoldi, E.: A survey of statistical network models. Found. Trend Mach. Learn. 2(2), 129Ð233 (2010) 46. Golub, G., Loan, C.V.: Matrix Computations. Johns Hopkins University Press, Baltimore (1996) 47. Gross, R., Acquisti, A.: Information revelation and privacy in online social networks. In: Proceedings of the 2005 Workshop on Privacy in the Electronic Society, pp. 71Ð80. ACM, Alexandria, VA, USA (2005) 48. Guimera, R., Amaral, L.N.: Functional cartography of complex metabolic networks. Nature 433(7028), 895Ð900 (2005) 49. Guimera, R., Mossa, S., Turtschi, A., Amaral, L.: The worldwide air transportation network: anomalous centrality, community structure, and cities’ global roles. Proc. Nat. Acad. Sci. 102(22), 7794 (2005) 50. Han, J., Kamber, M.: Data Mining: Concepts and Techniques, 2nd edn. Kaufmann, San Francisco (2006) 51. Hansen, D., Smith, M., Shneiderman, B.: Analyzing Networks with NodeXL: Insights from a Connected World. Elsevier, Burlington (2010) 52. Harel, D., Koren, Y.: A fast multi-scale method for drawing large graphs. In: Proceedings of the Conference on Advanced Visual Interfaces, pp. 282Ð285. New York, NY, USA (2000) 53. Jeh, G., Widom, J.: SimRank: a measure of structural-context similarity. In: Proceedings of the 8th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 538Ð543. Edmonton, Alberta, Canada (2002) 12 Extraction and Analysis of Facebook Friendship Relations 323

54. Jeong, H., Tombor, B., Albert, R., Oltvai, Z., Barabasi,« A.: The large-scale organization of metabolic networks. Nature 407(6804), 651Ð654 (2000) 55. Kim, M., Han, J.: CHRONICLE: a two-Stage density-based clustering algorithm for dynamic networks. In: Proceedings of the International Conference on Discovery Science. Lecture Notes in Computer Science, pp. 152Ð167. Springer (2009) 56. Kleinberg, J.: The small-world phenomenon: an algorithm perspective. In: Proceedings of the 32nd Symposium on Theory of Computing, pp. 163Ð170. ACM, Portland, OR, USA (2000) 57. Kleinberg, J.M.: Authoritative sources in a hyperlinked environment. J. ACM 46(5), 604Ð632 (1999) 58. Kumar, R., Novak, J., Tomkins, A.: Structure and evolution of online social networks. In: Link Mining: Models, Algorithms, and Applications, pp. 337Ð357. Springer, New York (2010) 59. Kurant, M., Markopoulou, A., Thiran, P.: On the bias of breadth first search (bfs) and of other graph sampling techniques. In: Proceedings of the 22nd International Teletraffic Congress, pp. 1Ð8. Amsterdam, The Netherlands (2010) 60. Latora, V., Marchiori, M.: A measure of centrality based on network efficiency. New J. Phys. 9, 188 (2007) 61. Leicht, E., Holme, P., Newman, M.E.J.: Vertex similarity in networks. Phys. Rev. E 73(2), 026120 (2006) 62. Leskovec, J.: Stanford network analysis package (SNAP). URL http://snap.stanford.edu/ 63. Leskovec, J., Faloutsos, C.: Sampling from large graphs. In: Proceedings of the 12th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, pp. 631Ð636. Philadelphia, PA, USA (2006) 64. Leskovec, J., Kleinberg, J., Faloutsos, C.: Graphs over time: densification laws, shrinking diameters and possible explanations. In: Proceedings of the 11th ACM SIGKDD Interna- tional Conference on Knowledge Discovery and Data Mining, pp. 177Ð187. Chicago, IL, USA (2005) 65. Leskovec, J., Lang, K., Mahoney, M.: Empirical comparison of algorithms for network community detection. In: Proceedings of the 19th International Conference on the World Wide Web, pp. 631Ð640. ACM, Raleigh, NC, USA (2010) 66. Mathioudakis, M., Koudas, N.: Efficient identification of starters and followers in social media. In: Proceedings of the International Conference on Extending Database Technology, pp. 708Ð719. ACM, Saint-Petersburg, Russia (2009) 67. McCown, F., Nelson, M.: What happens when Facebook is gone? In: Proceedings of the 9th Joint Conference on Digital Libraries, pp. 251Ð254. ACM, Austin, TX, USA (2009) 68. Milgram, S.: The small world problem. Psychol. Today 2(1), 60Ð67 (1967) 69. Mislove, A., Marcon, M., Gummadi, K., Druschel, P., Bhattacharjee, B.: Measurement and analysis of online social networks. In: Proceedings of the 7th ACM SIGCOMM Conference on Internet Measurement, pp. 29Ð42. ACM, San Diego, CA, USA (2007) 70. Newman, M.: Scientific collaboration networks. I. Network construction and fundamental results. Phys. Rev. E 64(1), 16131 (2001) 71. Newman, M.: The structure and function of complex networks. SIAM Rev. 45(2), 167 (2003) 72. Newman, M., Barabasi, A., Watts, D.: The Structure and Dynamics of Networks. Princeton University Press, Princeton/Oxford (2006) 73. Newman, M., Leicht, E.: Mixture models and exploratory analysis in networks. Proc. Nat. Acad. Sci. 104, 9564Ð9569 (2007) 74. Onnela, J., Reed-Tsochas, F.: The spontaneous emergence of social influence in online systems. Proc. Nat. Acad. Sci. 107, 18375 (2010) 75. Palla, G., Derenyi, I., Farkas, I., Vicsek, T.: Uncovering the overlapping community structure of complex networks in nature and society. Nature 435(7043), 814Ð818 (2005) 76. Palmer, C., Steffan, J.: Generating network topologies that obey power laws. In: Global Telecommunications Conference, vol. 1, pp. 434Ð438. IEEE (2002) 77. Partow, A.: General purpose hash function algorithms. URL http://www.partow.net/ programming/hashfunctions/ 78. Perer, A., Shneiderman, B.: Balancing systematic and flexible exploration of social networks. IEEE Trans. Vis. Comput. Graph. 12(5), 693Ð700 (2006) 324 S. Catanese et al.

79. Perer, A., Shneiderman, B.: Integrating statistics and visualization: case studies of gaining clarity during exploratory data analysis. In: Proceeding of the 26th Annual SIGCHI Conference on Human Factors in Computing Systems, pp. 265Ð274. ACM, Florence, Italy (2008) 80. Radicchi, F., Castellano, C., Cecconi, F., Loreto, V., Parisi, D.: Defining and identifying communities in networks. Proc. Nat. Acad. Sci. 101(9), 2658Ð2663 (2004) 81. Redner, S.: How popular is your paper? An empirical study of the citation distribution. Eur. Phy. J. B 4(2), 131Ð134 (1998) 82. Romero, D., Galuba, W., Asur, S., Huberman, B.: Influence and passivity in social media. In: Proceedings of the 20th International Conference Companion on World Wide Web, pp. 113Ð114. ACM, Hyderabad, India (2011) 83. Romero, D., Kleinberg, J.: The directed closure process in hybrid social-information networks, with an analysis of link formation on Twitter. In: Proceedings of the 4th International Conference on Weblogs and Social Media, Washington, DC, USA (2010) 84. Seidel, R.: On the all-pairs-shortest-path problem. In: Proceedings of the 24th Symposium on Theory of Computing, pp. 745Ð749. ACM, Victoria, BC, Canada (1992) 85. Snasel, V., Horak, Z., Abraham, A.: Understanding social networks using formal concept analysis. In: Proceedings of the Web Intelligence/IAT Workshops, pp. 390Ð393. IEEE, Sydney, Australia (2008) 86. Snasel, V., Horak, Z., Kocibova, J., Abraham, A.: Reducing social network dimensions using matrix factorization methods. In: International Conference on Advances in Social Network Analysis and Mining, pp. 348Ð351. IEEE, Athens, Greece (2009) 87. Song, X., Chi, Y., Hino, K., Tseng, B.: Identifying opinion leaders in the blogosphere. In: Proceedings of the 16th ACM Conference on Information and Knowledge Management, pp. 971Ð974. ACM, Lisbon, Portugal (2007) 88. Travers, J., Milgram, S.: An experimental study of the small world problem. Sociometry 32(4), 425Ð443 (1969) 89. Wasserman, S., Faust, K.: Social Network Analysis: Methods and Applications. Cambridge University Press, Cambridge/New York (1994) 90. Watts, D.: Small Worlds: The Dynamics of Networks Between Order and Randomness. Princeton University Press, Princeton/Woodstock (2004) 91. Watts, D., Strogatz, S.: Collective dynamics of small-world networks. Nature 393(6684), 440Ð442 (1998) 92. Wilson, C., Boe, B., Sala, A., Puttaswamy, K., Zhao, B.: User interactions in social networks and their implications. In: Proceedings of the 4th European Conference on Computer Systems, pp. 205Ð218. ACM, Nuremberg, Germany (2009) 93. Ye, S., Lang, J., Wu, F.: Crawling online social graphs. In: Proceedings of the 12th International Asia-Pacific Web Conference, pp. 236Ð242. IEEE, Busan, Korea (2010)