igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Calculate the edge attributes based on the vertices attribu


From: Tamás Nepusz
Subject: Re: [igraph] Calculate the edge attributes based on the vertices attributes
Date: Tue, 10 Apr 2012 10:29:50 +0200

> Hello, I have a directed graph(G),
> I have E(G)$Rates,
> and V(G)$Capacity,
> How can I create an edge attribute as E(from p1)$Weights = Origin
> V(p1)$Rate * E(from p1)$Capacity?

Please clarify if I didn't understand this correctly; you would like to make 
the weight of each edge be equal to its capacity multiplied by the rate of the 
source of the edge. This should work:

sources <- get.edgelist(G)[,1] + 1
E(G)$Weight <- V(G)$Rate[sources] * E(G)$Capacity

The "+ 1" at the end of the first line accounts for the fact that igraph vertex 
IDs start at zero but R's vectors are indexes from 1.

-- 
T.




reply via email to

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