igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] extract network stats for a subset of nodes


From: Gábor Csárdi
Subject: Re: [igraph] extract network stats for a subset of nodes
Date: Wed, 14 Oct 2009 13:58:52 +0200

On Mon, Oct 12, 2009 at 12:07 PM, Tamas Nepusz <address@hidden> wrote:
> Dear Will,
>
> I'm not an R expert, so there might be an easier way to do that, but
> this seems to work:
>
>> g <- grg.game(100, 0.2)
>> V(g)$name <- LETTERS
>> degree(g, which(V(g)$name %in% c("A", "F", "X")))

There is a small mistake here, the infamous 0-1 catch. Vertices are
numbered from zero, and which() returns indices starting from one. So
you need to subtract one.

It is a bit simpler to use match():
degree(g, match( c("A","F","X"), V(g)$name )-1)

G.

>
> --
> Tamas
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     UNIL DGM




reply via email to

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