Discussion:
[igraph] help about extracting the largest connected component
Ali Ilhan
2018-05-16 11:33:26 UTC
Permalink
Dear all,

I am pretty new to igraph and R, and having some difficulties (long time
Stata and SAS user). I have a graph of roughly 32000 vertices, which has a
largest component of around 6200 connected nodes. All I want to do is to
extract this as a new igraph object, and calculate some basic network
metrics such as density, mean degree centrality etc.

I have tried to various things which have been suggested before in this
list, such as:

giant.component <- function(graph, ...) {
cl <- clusters(graph, ...)
subgraph(graph, which(cl$membership == which.max(cl$csize)-1)-1)
}

tail.component <- function(graph, ...) {
cl <- clusters(graph, ...)
subgraph(graph, which(cl$membership != which.max(cl$csize)-1)-1)
}
But could not get the code to work. I have been mainly playing with
induce.subgraph and decompose.


Any help is greatly appreciated.


Warm wishes,

ali
Ali Ilhan
2018-05-16 12:32:52 UTC
Permalink
Dear all,

Sorry for taking your time again, but I solved the issue, I think it is a
version issue, the working code is below:

giant.component <- function(graph) {
cl <- clusters(graph)
induced.subgraph(graph, which(cl$membership == which.max(cl$csize)))}

Thanks again,

ali
Post by Ali Ilhan
Dear all,
I am pretty new to igraph and R, and having some difficulties (long time
Stata and SAS user). I have a graph of roughly 32000 vertices, which has a
largest component of around 6200 connected nodes. All I want to do is to
extract this as a new igraph object, and calculate some basic network
metrics such as density, mean degree centrality etc.
I have tried to various things which have been suggested before in this
giant.component <- function(graph, ...) {
cl <- clusters(graph, ...)
subgraph(graph, which(cl$membership == which.max(cl$csize)-1)-1)
}
tail.component <- function(graph, ...) {
cl <- clusters(graph, ...)
subgraph(graph, which(cl$membership != which.max(cl$csize)-1)-1)
}
But could not get the code to work. I have been mainly playing with induce.subgraph and decompose.
Any help is greatly appreciated.
Warm wishes,
ali
Continue reading on narkive:
Loading...