igraph-help
[Top][All Lists]

## Re: [igraph] Number of isolated nodes in the network

 From: Gábor Csárdi Subject: Re: [igraph] Number of isolated nodes in the network Date: Thu, 5 Aug 2010 11:05:45 +0200

```Claudia,

while you did not ask it explicitly, I guess your question is how to
do this with igraph. Pretty simple:

library(igraph)

el <- matrix(scan(path), byrow=TRUE, ncol=3)
g <- graph.edgelist(el[,1:2]-1)
sum(degree(g)==0)

will give you the number of isolates. Please see the manual page of
'graph.edgelist' and 'degree' for details. The '-1' is because igraph
vertex ids are numbered from zero, you don't need it if the input file

You'll need some more modifications if your vertex ids are not
consecutive or symbolic.

Best Regards,
Gabor

On Thu, Aug 5, 2010 at 4:50 AM, Claudia Muller-Birn <address@hidden> wrote:
> Dear all,
>
> I might have a fairly simple question but I have difficulties to solve my
> problem this time. I'd like to compute the number of isolates nodes in a
> network. This function is available in the sna package which I normally avoid
> to use. And now I know once again why:
>
> Error: cannot allocate vector of size 902.3 Mb
>
> Okay, but let's start from the beginning, here are my commands:
>
> library(igraph)
> library(sna)
>
> path <- 'timeframe40_edgelist.ncol'
>
> el <- matrix(scan(path), byrow=TRUE, ncol=3)
> g <- as.edgelist.sna(el)
> i <- isolates(g, diag=FALSE)
> length(i)
>
> My edge list has the following format (extract):
>
> 4372  4375  2
> 4372  4372  1
> 4375  4372  2
> 4375  4375  6
>
> Well, I'd really appreciate if anyone has an idea what I can do.
>
> Thank you.
>
> Claudia
>
>
>
> _______________________________________________
> igraph-help mailing list
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>

--