def set_edge_attributes(G, name, values):
 if (not isinstance(values, dict)):
  if G.is_multigraph():
   edges = G.edges(keys=True)
  else:
   edges = G.edges()
  values = dict(zip_longest(edges, [], fillvalue=values))
 if G.is_multigraph():
  for ((u, v, key), value) in values.items():
   G[u][v][key][name] = value
 else:
  for ((u, v), value) in values.items():
   G[u][v][name] = value

def set_edge_attributes ( G , name , values ) : if ( not isinstance ( values , dict ) ) : if G . is_multigraph ( ) : edges = G . edges ( keys = True ) else : edges = G . edges ( ) values = dict ( zip_longest ( edges , [ ] , fillvalue = values ) ) if G . is_multigraph ( ) : for ( ( u , v , key ) , value ) in values . items ( ) : G [ u ] [ v ] [ key ] [ name ] = value else : for ( ( u , v ) , value ) in values . items ( ) : G [ u ] [ v ] [ name ] = value
sets edge attributes from a given value or dictionary of values .