Search code examples
rigraphnetwork-analysis

what does "not strongly connected graph" means in centiserve centroid computation?


As in the question, I have four different networks which I load from 4 different csv files. Each one fails when I compute the centroid using centiserve library. On the other hand, if I generate a random ER network, the centroid computation works.

I looked into the centroid funcion and eventually I found it checks whether the network is connected using an igraph this function is.connected(g, mode="strong")

According to wikipedia a graph is strongly connected if all the nodes are reachable from a random node in the network. To this aim, I calculated the components of my network, using igraph's decompose() function and all the networks have a single connected component: length(decompose(net)) is always equal to 1. But, centroid(net) is always returning the error.

Eventually, the question is: What exactly is this function looking for when it verifies if the graph is suitable? Why my network has a single connected component but the is.connected() function of igraph return False?

Some code:

#load file
finalNet <- read.csv("net.csv", sep=",", header=T)
#get network
net <- graph_from_data_frame(finalNet[, c(1, 2)])
#decompose says that there is a single connected component
length(decompose(net))
#while centroid does not work!
centroid(net)

the network is available here


Solution

  • ok, I found the answer. The problem is that the function graph_from_data_frame create a directed network, if not specified otherwise.

    Hence, the solution to make my example work is to load the network as not directed:

    net <- graph_from_data_frame(finalNet[, c(1, 2)], directed=F)