I am trying to combine two graphs with the same nodes, but so that the new weight of the edge of the graph is the sum of the two original graphs (but, of course, I want the solution to go on to N graphs):
g1 <- graph.empty(directed=FALSE) + vertices(letters[1:2])
g1 <- g1 + edge("a", "b")
E(g1)$weight <- 1
g2 <- graph.empty(directed=FALSE) + vertices(letters[1:2])
g2 <- g2 + edge("a", "b")
E(g2)$weight <- 2
g3 <- g1 %u% g2
E(g3)$weight_1
E(g3)$weight_2
But I want the weight of E (g3) $ to be 3.
Is there a more elegant way to do this than summing over the weights of the edges _1, _2, ... after? Something like simplification / contract?
source
share