SNA Assignment - Centrality: Harshit Kumar Singh 19BM63058

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

SNA Assignment – Centrality

Harshit Kumar Singh 19BM63058

Telling a Story with Networks: Positional Features


Positional Features: Positional features are node-level properties associated with occupying a
particular place or performing a particular role in a network.

Positional features are frequently measured using power and centrality measures. There are numerous
measures, many tailored to specific research questions such as optimizing web searches or identifying
important positions in influence networks.

Common positional features include: Degree, Closeness Centrality, Betweenness Centrality, and
Eigenvector Centrality.

Degree Centrality:
A node’s degree centrality refers to the number of ties it has

In-Degree Centrality: A node’s in-degree centrality refers to the number of ties it receives.

Out-Degree Centrality: A node’s out-degree centrality refers to the number of ties it sends.
Interpretation -

Harshit(me) would have the highest centrality in this term as it is mine network. In this case the in and
out both remain mostly same as it has been drawn my me taking in consideration that if person 1 talks
or communicate with person 2 it would be vice – versa too. For cases like Kanti, Awaneesh Aditya &
Nanhe the score differs because my mother Kanti knows them well because they al are my closest friend
but would or would not be the same case vice -versa

Closeness Centrality:
The closeness centrality of a node is the average length of the shortest path between the node and all
other nodes. The most central the node the closer it is to all the other nodes.

Closeness centrality like degree centrality can be calculated in terms of closest to (incoming ties) and
from (outgoing ties) in directed networks.
Interpretation – There is a perfect score of 1 for me in this case as all of them are mine connections

After me , my mother Kanti seems to be the most central in this case

Sudhish, Arpit, Akanksa, Ameesha, Gaurav & Anil are having the same score as they are all my family
members living under same roof.

Betweeness Centrality: A node’s betweenness centrality is the number of times a node acts as a bridge
along the shortest path between two other nodes

Betweeness Centrality is calculated by:

1. For each pair of nodes, compute the shortest paths between them.
2. For each pair of nodes, determine the fraction of shortest paths through the node in question.
3. Sum this fraction over all pairs of nodes.

Interpretation –

The ones with 0 symbolises that they don’t fall in any of the shortest path to any of the nodes. This wold
be due to in family onnections my mother Kanti connects all. In friends, Aditya & Ojha connects all. And
in college colleague Sameer , Satyam and Spandan Connects the whole network

Eigenvector Centrality: A node’s eigenvector centrality measures its influence in terms of how
connected the node to other highly connected nodes.

Frie Friend
nd 1 2
0.36 0.49

H 0.54
ar
sh
it( Ex
m
0.19 0.49 Ex te 0.17
e) Famil nd
te
Famil y1 ed
nd
y2 ed Fa
Fa0.17 mi
mi ly
ly 1
2
Overall Network Centrality

R Code
#adding library for SNA
library(readr)
library(igraph)
nodes=read.csv("node1.csv",header = T)

ties=read.csv("ties2.csv",header = T)
g=graph_from_data_frame(d=ties,directed= TRUE)
set.seed(222)
plot(g, vertex.color= "green", vertex.size= 25,edge.arrow.size=0.3, vertex.label.size=0.6)
V(g)
degree(g)
adj = get.adjacency(g,attr=NULL, names=TRUE, sparse=FALSE)
V(g)$degree=degree(g)
plot(g, vertex.color= "green", vertex.size= V(g)$degree*0.4 ,edge.arrow.size=0.1,
layout=layout.fruchterman.reingold)
plot(g, vertex.color=nodes$col[match(V(g)$name,nodes$Name)], vertex.label.color="black",vertex.size= V(g)
$degree ,edge.arrow.size=0.2,vertex.label.font=2, layout=layout.kamada.kawai)

a=data.frame(get.edgelist(g))
a$names=paste(a[,1],a[,2],sep="->")
ties$name=paste(ties$From,ties$To,sep="->")

ties$weight=ifelse(is.na(ties$weight),0.2,ties$weight)

E(g)$weight = ties$weight[match(a$name,ties$name)]

plot(g, vertex.color=nodes$col[match(V(g)$name,nodes$Name)], vertex.size= V(g)$degree ,


edge.arrow.size=0.2, edge.width=E(g)$weight, edge.color=E(g)$weight*10,vertex.label.font=2,
layout=layout.kamada.kawai)

##Degrees of Centrality using igraph package


degree.cent <- centr_degree(g, mode = "all")
degree.cent
closeness.cent <- centr_clo(g, mode="out")
closeness.cent
betweenness.cent <- centr_betw(g, directed = TRUE)
betweenness.cent
##Degrees of Centrality using igraph package
centralization.degree(g)
centralization.betweenness(g)
centralization.closeness(g)
##Degrees of Centrality using igraph package
degree(g)
degree(g, mode = "out")
degree(g, mode = "in")
closeness(g, mode="all",weights = NA,normalized=TRUE)
closeness(g, mode="in",weights = NA,normalized=TRUE)
closeness(g, mode="out",weights = NA,normalized=TRUE)
##Degrees of Betweeness using igraph package
betweenness(g, weights = NA)
edge_betweenness(g, weights = NA,directed=TRUE)
##Eigen Centrality
eigen_centrality(g, weights = NA,directed=TRUE)

You might also like