Network centrality measures

Analyzing Social Media Data in R

Sowmya Vivek

Data Science Coach

Lesson overview

  • Concept of network centrality measures
  • Degree centrality and betweenness
  • Identify key players in the network and their role in a promotional campaign
Analyzing Social Media Data in R

Network centrality measures

  • Influence of a vertex is determined by the number of edges and its position
  • Network centrality is the measure of importance of a vertex in a network
  • Network centrality measures assign a numerical value to each vertex
  • Value is a measure of a vertex's influence on other vertices
Analyzing Social Media Data in R

Degree centrality

  • Simplest measure of vertex influence
  • Determines the edges or connections of a vertex
  • In a directed network, vertices have out-degree and in-degree scores
Analyzing Social Media Data in R

Out-degree

Out_degree

Analyzing Social Media Data in R

In-degree

In_degree

Analyzing Social Media Data in R

Degree centrality of a user

library(igraph)
# Calculate out-degree
out_deg <- degree(nw_rtweet, 
                  "OutfitAww", 
                   mode = c("out"))
out_deg
OutfitAww 
    20
library(igraph)
# Calculate in degree
in_deg <- degree(nw_rtweet, 
                 "OutfitAww", 
                  mode = c("in"))
in_deg
OutfitAww 
   23
Analyzing Social Media Data in R

Users who retweeted most

# Calculate the out-degree scores
out_degree <- degree(nw_rtweet, mode = c("out"))
# Sort the users in descending order of out-degree scores
out_degree_sort <- sort(out_degree, decreasing = TRUE)
Analyzing Social Media Data in R

Users who retweeted most

# View the top 3 users
out_degree_sort[1:3]
VanesEtim   RedNileShop     w3daily 
  209           147            62
Analyzing Social Media Data in R

Users whose posts were retweeted most

# Calculate the in-degree scores
in_degree <- degree(nw_rtweet, mode = c("in"))
# Sort the users in descending order of in-degree scores
in_degree_sort <- sort(in_degree, decreasing = TRUE)
Analyzing Social Media Data in R

Users whose posts were retweeted most

# View the top 3 users
in_degree_sort[1:3]
XyC_129    SocialBflyMag      jisoupy 
  171           167             142
Analyzing Social Media Data in R

Betweenness

  • Degree to which nodes stand between each other
  • Captures user role in allowing information to pass through network
  • Node with higher betweenness has more control over the network

Betweenness

Analyzing Social Media Data in R

Identifying users with high betweenness

# Calculate the betweenness scores of the network
betwn_nw <- betweenness(nw_rtweet, directed = TRUE)
# Sort the users in descending order of betweenness scores
betwn_nw_sort <- betwn_nw %>%
                   sort(decreasing = TRUE) %>%
                   round()
Analyzing Social Media Data in R

Identifying users with high betweenness

# View the top 3 users
betwn_nw_sort[1:3]
GuruOfficial   Home_and_Loving    SimplyTasheena 
   65                54                40
Analyzing Social Media Data in R

Let's practice!

Analyzing Social Media Data in R

Preparing Video For Download...