igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Claudia Muller-Birn
Subject: Re: [igraph] Number of isolated nodes in the network
Date: Thu, 5 Aug 2010 23:40:28 -0400

Hi Gabor,

On Aug 5, 2010, at 5:05 AM, Gábor Csárdi wrote:

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

:) True, I missed it. I just assumed that people would understand. 

> 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.

Well, simple, but even after the first couples of months with igraph 
unfortunately still a barrier.

> 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
> is already zero based.

Very good point, I have to keep this in mind! (I am often wondering about this 
'-1' in other calculations...)

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

Which brings me to another question, but this is not related to this thread and 
it is a long story. I'll need a bit more time for it, but I'll ask it soon :)

Thank you all again. This list is very helpful!

Claudia


> 
> 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
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>> 
> 
> 
> 
> -- 
> Gabor Csardi <address@hidden>     UNIL DGM
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help




reply via email to

[Prev in Thread] Current Thread [Next in Thread]