[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Combing vertex/edge attributes within a graph
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] Combing vertex/edge attributes within a graph |
Date: |
Sat, 21 Dec 2013 23:43:20 +0100 |
> The short explanation is that I would like to do some math involving the
> vertex and edge attribute values of two graphs.
[…]
>
> I can construct an attrib name variable:
> > attrib <- list.vertex.attributes(gA)
>
> ...but the problem I seem to be having is constructing the combined 'total'
> attribute which involves indexing over the names of all the attributes, for
> example: V(gA)$attrib[i] e.g. V(gA)$(area[i], aspect[i], ..., Ot[i])[i].
You could try constructing a data frame that contains the vertex attributes in
the columns and the vertices in the rows, and then use apply() to apply a
function to each row in the data frame:
g <- grg.game(100, 0.2)
V(g)$a <- 1:100
V(g)$b <- 100:100
df <- data.frame(a=V(g)$a, b=V(g)$b)
V(g)$total <- apply(df, 1, my.combinator.function)
where my.combinator.function must be your combinator function.
T.