I have a list of edges with weights and I want to get the disjoint set from them. However, I want to track the weights also in the set. e.g If I have a dataset,
N1 N2 Weight
a1 a2 1.0
a2 a3 0.5
a3 a5 1.0
a4 a8 1.0
a8 a9 0.8
It will result in two sets
[(a1,1.0), (a2,1.0), (a3,1.0*0.5), (a5,0.5*1.0)] and [(a4,1.0),(a8,1.0), (a9,1.0*0.8)]
essentially the weights in the relationships gets multiplied by the weight. Is there any efficient algorithm to track this other than brute forcing? The language of choice is python.