I have performed a community detection algorithm on my network and have a list of clusters as output. I would like to do several things with these clusters but am struggling with how to manipulate them. To start with I would like to create subgraphs by referencing eg Cluster 1. Below is some of my code.
I have a dataframe that looks like this
Person1   Person2 Volpc
Person A    Person B    0.08
Person A    Lady A  0.08
Person A    Lady B  0.23
Person A    Lady C  0.38
Lady B  Mr CC   0.29
Lady B  Lady A  0.23
Lady B  Person B    0.87
Lady C  Lady A  0.87
Lady C  Lady B  1.01
Mr D    Mr CC   0.94
#First I created an adjacency matrix from by data set of links LinkSummary for which
#the weight is named Volpc
G <- graph.data.frame(LinkSummary,directed=FALSE);
A <- as_adjacency_matrix(G,type="both",names=TRUE,sparse=FALSE,attr="Volpc");
#build a graph
netw <- graph.adjacency(A,weighted=T, mode="undirected")
#remove loops
netw <- simplify(netw)
#I used the walktrap algorithm to find communities
wt<- walktrap.community(netw, steps=6,modularity=TRUE,weights = E(G)$Volpc)
I have been experimenting with the number of clusters to find the best solution.
 Without this option a lot of the nodes were placed in one massive cluster.  This helped to break them up.
#increase number clusters
wt2 <- cut_at(wt, no=300)
I put the results into a table and outputted them to excel and produced something that looked like this
memtwt <- table(names, wt2 )
write.table(memtwt, file="clipboard-16384", sep="\t", row.names=TRUE) increase buffer
Node   1    2   3   4
Person A    1   0   0   0
Lady A  0   1   0   0
Lady B  1   0   0   0
Lady C  0   0   0   1
Mr D    0   0   1   0
Person B    0   0   1   0
Mr CC   1   0   0   0  
Unfortunately it looks like a lot of my clusters are based on ties with one node. To view the interactions I created a subnetwork (using code from here Creating Subgraph using igraph in R)
# we want a sub-network containing the following nodes:
subv <- c('Person A','Lady B','Mr CC')
# create a sub-network composed by ONLY the nodes in subv and the edges 
# between them
g2 <- induced.subgraph(graph=netw,vids=subv)
plot(g2,  vertex.size=3, edge.color="black",edge.width=E(g2)$weight/10)
What I would like is to be able to assign each cluster to a variable so that I can view the subnetworks each time I have different results without typing out a list of names, something like this...
subv <- wt2(1)
g3 <- induced.subgraph(graph=netw,vids=subv)
Can anyone help me please?
 
    