## Graph theory applied to social media analysis

For a few years now we can say that the increase in the use of social networks has been exponential, Facebook, Twitter, Instagram and LinkedIn are already part of our daily lives. In addition, social networks have become more important in terms of the creation and distribution of information. This means that the volume of information and its need for analysis has to be carried out in Big Data and Business Intelligence environments. In this way, it is possible to obtain prescriptive information for companies (such as information collected with the theory of graphs).

It can be said that social networks consist of establishing and working relationships between people. In this way, it is possible to create a network of different people united by a “friendship” or contact, similar to the one we can see below.

In this image we can see how each point (or also called node) represents a person, and each edge (or line of connection) establishes the friendship between those two people. In this way thanks to the graph theory we can study the patterns, increasing the business intelligence.

### What is graph theory

The first thing you should know is that a graph is a mathematical structure that allows you to represent everyday problems in a graphic way. In addition, network theory allows you to represent only one type of relationship (simple representation), but it also allows you to represent more than one type (in that case, it would be called multiple).

Even eminent figures such as the founder of Facebook, Mark Zuckenberg, have spoken of “social graphs” to represent the connections and relationships that users of the social network have.

Graph theory is a branch of mathematics, the same branch that is also used in computer science. It is based on both discrete and applied mathematics. In this way, it manages to encompass different concepts.

### Applying graph theory to social networks

Let’s think about the commercial strategy that any telecommunication company seeking to know the composition of the links would carry out. You would be interested in knowing which people we usually talk to and thus adapt your commercial strategy to offer personalized offers and/or rates.

In addition to this, applying the networks to social networks can work to adapt the products to the real needs, making them appear at the right time.

When we talk about networks applied to social networks the most common is that they are used to “detect communities”. Thanks to the algorithms we can see characteristics, attributes and relationships that match within a group. When we analyze the subnetworks, we can see the vertices that are most related to each other, and also how they relate to the rest of the vertices.

If we look at the graph above, we can see that three different communities have been detected, in which we can assume that all the members of the same community have characteristics or attributes that coincide.

### Methods for detecting communities

Within the graph theory, different methods are used to analyze and detect communities, usually grouped by

- The hierarchical method: Thanks to it, natural divisions are sought in the network. This method is based on the fact that networks usually have a hierarchical structure.
- The modular method: in this method they will focus on finding modularity (i.e. the metric that compares the internal modules of a community).

The graph theory together with these methods, can be applied by a Data Scientist, using R, igraph among others (for example with these technologies would get to know the clustering coefficient, the minimum path between nodes and the distribution of the graphs.