I have the following problem:
I have the following graph: g6 which does not include isolate vertices. The vertices are mainly grouped into two ethnic groups, given as attribute, namely: mestizo and saraguro.
So I run the subgraphoption for saraguros as follows:
g2saraguro <- subgraph(g6, which(V(g6)$ethnic==”saraguro”))
summary(g2saraguro)
which did work:
Vertices: 166
Edges: 330
Directed: TRUE
No graph attributes.
Vertex attributes: ii, village, parroquia, canton, provinz, kindR, ethnic, situation, researcha.
Edge attributes: question, activity.
However, if I try the same with mestizo, there is a proble, since it just identify:
s2mestizo <- subgraph(g6,V(g6)$ethnic==”mestizo”)
summary(s2mestizo)
Vertices: 2
Edges: 3
Directed: TRUE
No graph attributes.
Vertex attributes: ii, village, parroquia, canton, provinz, kindR, ethnic, situation, researcha.
Edge attributes: question, activity.
but in the reality that is no the case, if I see: V(g6)$ethnic, mestizo are the majority !!
I really don´t know where the problem is, with igraph 0.6 the procedure to form a subgraph should be in that or a similar way, without 1-based indexing.
thanks a lot for any help
regards
Vladimir
You forgot to use the
whichfunction in the second case; i.e., instead ofyou should write
Also note that if you are using igraph 0.5.x or earlier, you must subtract 1 from the result of
whichbecause of the 0-based indexing of igraph. This has been fixed in igraph 0.6 so you don’t need to subtract 1 if you are using igraph 0.6 or later.Edit: based on your recent comment, it looks like you are using igraph 0.5.x or earlier (because the output format of
summaryis different for 0.6). In this case, you must subtract 1 from the result ofwhichbecause igraph 0.5.x and earlier versions use zero-based vertex indices. Therefore, the correct line should be: