1
votes

I used the igraph library installed in R software and I want to extract an ego-network from the network "Les Miserables".

Here is my code:

library("igraph")
lesmis<-read.graph("lesmis.gml", format="gml")
gavroche <- graph.neighborhood(lesmis, order = 2, nodes = which(V(lesmis)$label == "Gavroche"))
wc<-infomap.community(gavroche)
plot(wc, gavroche)

I get this error :

Error in infomap.community(gavroche) : Not a graph object

here is the link of the gml file : http://www-personal.umich.edu/~mejn/netdata/lesmis.zip

1
graph.neighborhood returns a list of graphs, always, so you need to extract the first (and only) element. - Gabor Csardi
Thank you, in fact, i want to extract the egocentric network of Gavroche as a graph and display the detected communities in output graph. - Mamadou Ba

1 Answers

0
votes

I've reached this question just now searching for other theme. I found that the object created by graph.neighborhood is not a graph itself but a list instead, that in turn contains your expected graph. Then you can replace:

wc <- infomap.community(gavroche[[1]])
plot(wc, gavroche[[1]])

And it must work.