igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] how to change attribute value


From: Gábor Csárdi
Subject: Re: [igraph] how to change attribute value
Date: Fri, 29 Oct 2010 17:46:50 +0200

Hi Simone,

On Fri, Oct 29, 2010 at 5:38 PM, Simone Gabbriellini
<address@hidden> wrote:
> Hello List,
>
> I have two node attributes, name and colorname. I then have a list of values 
> containing some of the nodes names. I would like to change the value of 
> colorname for just the listed nodes.
>
> I am using this but without success:
>
> V(g)[name == listOfNodeNames]$colorname<-"violet"

This is not good, 'name' and 'listOfNodeNames' are two vectors after
all. You cannot say

v1 <- c(1,2,3)
v2 <- c(3,5,6,7,8)
v1 == v2

in R after all. (Well, you can, but it does not make sense.)

One way to do what you want is

V(g)[name %in% listOfNodeNames]$colorname <- "violet"

Best,
Gabor

> thanks for the help,
> Simone
> _______________________________________________
> 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]