A_P
A_P

Reputation: 13

Social Network Analysis and Component size - igraph R SNA

I have a social network of approximately 1,400 cases and partners. I am using igraph to create the network and also extract some metrics (density, average degree, betweenness etc)

I want to analyze the data by component size (create categories for small components (2-3 members), medium components (8-20 members) and large components(more than 20 members)

Using the following code: components<-components(allcases.g) I get some information such as: $membership, $scize and $number.

However, $csize just tells me the size of all of the the different components (total= 250 components), but the size is not linked to the individual vertices.

Does anybody know the best way to link back the component size to each of the vertices in my network?

Thanks!

Upvotes: 1

Views: 467

Answers (1)

G5W
G5W

Reputation: 37661

membership tells you which component a node belongs to. As you noted, csize tells you the size of the component. So you can get the size of the components by node using COMP$csize[COMP$membership]. Here is a small example.

library(igraph)
set.seed(1234)
g = erdos.renyi.game(30, 0.15) + 
    erdos.renyi.game(30, 0.15) +
    erdos.renyi.game(20, 0.25) +
    erdos.renyi.game(20, 0.25)
plot(g, vertx.size=6, cex=0.8, margin=-0.2)

COMP = components(g)
COMP$csize[COMP$membership]
  [1] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
 [26] 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30
 [51] 30 30 30 30 30 30 30 30 30 30 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
 [76] 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20

Upvotes: 3

Related Questions