Hi, On Fri, Dec 4, 2009 at 3:12 AM, Gaurav Kumar <gau...@gauravkumar.org> wrote: > Hi R-users, > > I'm using igraph for an undirected graph. > i used clusters() igraph function to know the component size(subgraphs) as > shown bellow: > c <-clusters(g) > # component sizes > size <- sort(c$csize, decreasing=TRUE) > cat("Top 20 cluster of the graph","\n") > for (i in 1:20) > { > cat(i," size:",size[i] ,"\n") > } > > Can anyone help how to extract the subgraph components based on the size as > edgelist-format.
V(g)$name <- seq_len(vcount(g))-1 lapply(head(order(c$csize, decreasing=TRUE), 20), g, c$membership, FUN=function(w, g, m) { get.edgelist(subgraph(g, which(m==w-1)-1)) }) This gives you the largest 20 components. Best, Gabor ps. there is also an igraph-help mailing list, see http://igraph.sf.net. Just in case you get no answer on R-help. > Thanks in advance > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Gabor Csardi <gabor.csa...@unil.ch> UNIL DGM ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.