def _weight_function(G, weight):
 if callable(weight):
  return weight
 if G.is_multigraph():
  return (lambda u, v, d: min((attr.get(weight, 1) for attr in d.values())))
 return (lambda u, v, data: data.get(weight, 1))

def _weight_function ( G , weight ) : if callable ( weight ) : return weight if G . is_multigraph ( ) : return ( lambda u , v , d : min ( ( attr . get ( weight , 1 ) for attr in d . values ( ) ) ) ) return ( lambda u , v , data : data . get ( weight , 1 ) )
returns a function that returns the weight of an edge .