def min_weight(graph, src, dst, n):
 default = {'weight': np.inf}
 w1 = graph[n].get(src, default)['weight']
 w2 = graph[n].get(dst, default)['weight']
 return {'weight': min(w1, w2)}

def min_weight ( graph , src , dst , n ) : default = { 'weight' : np . inf } w1 = graph [ n ] . get ( src , default ) [ 'weight' ] w2 = graph [ n ] . get ( dst , default ) [ 'weight' ] return { 'weight' : min ( w1 , w2 ) }
callback to handle merging nodes by choosing minimum weight .