igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] creating edge attribute from similarity on vertex attribute


From: Gábor Csárdi
Subject: Re: [igraph] creating edge attribute from similarity on vertex attribute
Date: Mon, 21 Jul 2014 15:50:38 -0400

Hi,

query the edge list with get.edgelist() and then create a matrix from
this, that contains the vertex attribute you want to use. You can then
create the edge attribute from this matrix. Something like this
(untested):

el <- get.edgelist(speakers)
el2 <- matrix(V(speakers)$birthyear[el], ncol=2)

E(speakers)$ageband5 <- abs(el2[,1] - el2[,2]) <= 5

Gabor

On Thu, Jul 17, 2014 at 10:25 AM, Richard Benton
<address@hidden> wrote:
> Hi All,
> I'm working with igraph in R and I'm trying to create an edge attribute in
> my network based on nodes' similarity on a vertex attribute. I already have
> the vertex attribute read into the igraph object.
>
> For example, "speakers" is an igraph object with vertex attribute
> "birthyear." I want to create an edge attribute "ageband5" with value 1 if
> two vertices in a dyad have birthyear within 5 years from one another.
> Alternatively, "birthyeardiff" could be an edge attribute that is the
> difference between the "birthyear" of each vertex in a dyad.
> How can this be done?
> Thank you,
> Richard
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>



reply via email to

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