igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Get different set of neighbour nodes with very similar code


From: Gábor Csárdi
Subject: Re: [igraph] Get different set of neighbour nodes with very similar code - Unexpected results
Date: Fri, 6 May 2011 11:04:30 -0400

I think you have a vertex attribute called 'id' in your graph.

The vertex set indexing operator automatically uses attribute names in
index expressions, e.g.

V(g)[name=="v2"]

works. This seemed to be a good idea back then, but it causes
confusion if there are variables with the same name. So this feature
might be removed in the next version of igraph.

HTH,
Gabor

On Fri, May 6, 2011 at 7:42 AM, Jimmy Dubuisson
<address@hidden> wrote:
> Hello,
>
> I try to get the set of neighbours of a given node (specified by its name)
> in R. If I do:
>
> vb <- V(g)[V(g)$name == "v2"]
> nvb <- V(g)[nei(vb)]
> print(nvb$name)
>
> I get the set of node "v2" neighbours as expected. But if I do:
>
> nv <- function(g, id)
> {
>   vb <- V(g)[V(g)$name == id]
>   V(g)[nei(vb)]
> }
>
> print(nv(g, "v2")$name)
>
> I get the whole set of g nodes!? Someone could explain why?
>
> Cheers,
>
> Jim.
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



-- 
Gabor Csardi <address@hidden>     MTA KFKI RMKI



reply via email to

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