igraph-help
[Top][All Lists]
Advanced

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

[igraph] adding weights after graph.union.by.name


From: Tony Larson
Subject: [igraph] adding weights after graph.union.by.name
Date: Wed, 24 Oct 2012 17:26:03 +0100


Hello,
I'm using graph.union.by.name in R to merge graphs with overlapping vertex symbolic names.  The original graphs also have edge weights, and the way I made them is such that the edge between any two vertices with matching symbolic names will always have identical edge weights.  Is there any way, after running the union, to add back in the weights?  e.g.

g3 <- graph.union.by.name(g1, g2)

I thought of using match in R to identify matching edges thus:

m1 <- match(E(g3), E(g1))
m2 <- match(E(g3), E(g2))

and then using:

E(g3)$weight[m1] <- E(g1)$weight
E(g3)$weight[m2] <- E(g2)$weight

but this fails as match seems to be using the updated edge IDS in the merged dataset (as expected, I guess).


any suggestions would be most welcome

thanks
Tony







reply via email to

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