I'm trying to make a program to illustrate the simplify process of a complex resistence network. I create a graph to represent the structure of the network and trying to use EdgeWeight to symbolize the value of resistence. but sometimes I'll need to deal with parallel resistence, so assigning EdgeWeight to them will be a problem.
In simple graphs, one can use:
gg=Graph[{1<->2,2<->3,3<->1},EdgeWeight->{1,2,3}]
to specify the weight of each edge. Then we can use PropertyValue to extract them:
PropertyValue[{gg,#},EdgeWeight]&/@EdgeList@gg
{1,2,3}
But in a non-simple graph:
gg=Graph[{1<->2,1<->2,2<->3},EdgeWeight->{1,2,3}]
It seems that EdgeWeight simply ignored the weight assignment for parallel edges and consider all parallel edges to be the same:
PropertyValue[{gg, #}, EdgeWeight] & /@ EdgeList@gg
{1,1,3}
This put a great barrier on my programming, so how to solve this problem? How to allow multiple EdgeWeight assigned to parallel edges?
Comments
Post a Comment