Hafiz Mohsin
Hafiz Mohsin

Reputation: 21

Reason why reciprocity of a network is 0 while using igraph in R

I am trying to calculate the reciprocity of a network containing a large no of edges and nodes. I don't know why the reciprocity of the network is 0 although there is not isolated node with degree 0. what could be the other reason that reciprocity is 0 except the isolated nodes impacting the connectivity in the network. the reciprocity of the network should not be 0 as it is a connected graph. I am using igraph library in R (R version 4.0.0). Below is the code

graph<- read.csv("data.csv")
bt_graph=graph_from_data_frame(subset(graph, select=c(source,target)),directed=TRUE)
bt_conn<- delete.vertices(bt_graph,which(degree(bt_graph)==0))  #deleting nodes with 0 degree
reciprocity_bt <- reciprocity(bt_conn, mode = "default")

Upvotes: 2

Views: 311

Answers (1)

G5W
G5W

Reputation: 37661

Reciprocity being zero does not mean disconnected. It means that there are no bi-directional connections. Here is a brief quote from the Wikipedia article on Reciprocity

With this definition, r = 1 is for a purely bidirectional network while r = 0 for a purely unidirectional one.

Here is a very small example.

library(igraph)

EL <- matrix( c(1,2,1,3), nc = 2, byrow = TRUE)
g = graph_from_edgelist(EL)
reciprocity(g)
[1] 0
plot(g)

Connected graph with reciprocity zero

There are no links that go A -> B -> A so reciprocity is zero.

Upvotes: 1

Related Questions