In R, I have a weighted undirected graph as an igraph object :
IGRAPH 60a5b9d UNW- 2777 19103 --
+ attr: name (v/c), label (v/c), nom (v/c), sigle (v/c), statut (v/c), champ (v/c), cp (v/c), info (v/c),
+ edges from 60a5b9d (vertex names):
[1] 0--35 1--9 1--199 1--484 2--171 2--483 2--978 2--3564 3--9 3--1464 3--1474 3--2981 4--75 6--18 6--25
[16] 6--28 6--33 6--64 6--65 6--71 6--86 6--87 6--101 6--104 6--113 6--118 6--144 6--166 6--182 6--183
+ ... omitted several edges
What I'm trying to do is, in the most elegant and simple way, to sum the weights of edges from a certain type of vertex to another one, and add the result as a vertex attribute.
In other words, I am not sure how I can, for each vertex that matches V(net)$attribute == "value"
, list all the edges to vertices that match V(net)$attribute == "value2"
, and then sum the weights. And I don't know if igraph is the best option to do that kind of operation, or if I should work with and edge data frame and a vertex data frame.