3

I have a list containing a network for each row (sna.list.1). For each of the networks, I need to extract a subgraph where only women are included, in order to calculate the density of women-only networks. I have created a loop function to set vertex attributes

female=vector()
for (i in 1 : length (sna.list.1))
  set.vertex.attribute(sna.list.1[[i]],"Female",alter.list.1bis[[i][,"NIDemo1_c4"])

but when I tried to create the subgraph with get.inducedSubgraph I receive a warning message saying " Illegal vertex selection in get.inducedSubgraph". The same formula works if I applied it to just one row/network.

subnetwork2=vector()
for (i in 1 : length (sna.list.1))
subnetwork2[[i]]=get.inducedSubgraph(sna.list.1[[i]],v=which(sna.list.1[[i]]%v%"Female"=="1"))

does anyone have suggestions?

skyebend
  • 1,079
  • 6
  • 19
Fede
  • 31
  • 2
  • I think this is not `igaph`, at least `igraph` does not have a `get.inducedSubgraph` function. – Gabor Csardi Aug 18 '15 at 13:27
  • it appears that you are using the `network` package, but without some additional code context I can't really tell what you are doing. I'm not sure what you mean by "list containing a network for each row" – skyebend Aug 26 '15 at 00:05

1 Answers1

0

Assuming that get.inducedSubgraph isolated alters is a continuation of your issue, it sounds like you were trying to induce a subgraph of size zero. i.e. v=which(sna.list.1[[i]]%v%"Female"=="1") was returning integer(0) for some networks.

Ideally, since the network package supports networks of size zero (no vertices) get.inducedSubgraph() should return a network of size zero in this case, but it does not yet do that.

Community
  • 1
  • 1
skyebend
  • 1,079
  • 6
  • 19