I have a Weighted Graph of g
which looks like this.
vertex = {a, b, c, d, e}
SeedRandom[1]
g = Graph[#[[1]] -> #[[2]] & /@ Permutations[vertex, {2}],
VertexLabels -> Placed["Name", Center], VertexSize -> 0.3,
EdgeWeight ->
RandomReal[{10, 20},
Count[#[[1]] -> #[[2]] & /@ Permutations[vertex, {2}], _]],
EdgeLabels -> "EdgeWeight"]
Could you please help me to merge two or even more vertices from g
(Please just g
I used Permutations
just to build a graph), in the way that in the end, I have a graph with added up the weights of the previous edges.For example, if vertices a
and b
merged together, in new vertex all of weights from old edges added up together to have new edges weights with connected vertices?