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
<[email protected]> 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
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>

_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to