def weight_boundary(graph, src, dst, n):
 default = {'weight': 0.0, 'count': 0}
 count_src = graph[src].get(n, default)['count']
 count_dst = graph[dst].get(n, default)['count']
 weight_src = graph[src].get(n, default)['weight']
 weight_dst = graph[dst].get(n, default)['weight']
 count = (count_src + count_dst)
 return {'count': count, 'weight': (((count_src * weight_src) + (count_dst * weight_dst)) / count)}

def weight_boundary ( graph , src , dst , n ) : default = { 'weight' : 0.0 , 'count' : 0 } count_src = graph [ src ] . get ( n , default ) [ 'count' ] count_dst = graph [ dst ] . get ( n , default ) [ 'count' ] weight_src = graph [ src ] . get ( n , default ) [ 'weight' ] weight_dst = graph [ dst ] . get ( n , default ) [ 'weight' ] count = ( count_src + count_dst ) return { 'count' : count , 'weight' : ( ( ( count_src * weight_src ) + ( count_dst * weight_dst ) ) / count ) }
handle merging of nodes of a region boundary region adjacency graph .