def get_edge_attributes(G, name):
 if G.is_multigraph():
  edges = G.edges(keys=True, data=True)
 else:
  edges = G.edges(data=True)
 return {x[:(-1)]: x[(-1)][name] for x in edges if (name in x[(-1)])}

def get_edge_attributes ( G , name ) : if G . is_multigraph ( ) : edges = G . edges ( keys = True , data = True ) else : edges = G . edges ( data = True ) return { x [ : ( - 1 ) ] : x [ ( - 1 ) ] [ name ] for x in edges if ( name in x [ ( - 1 ) ] ) }
get edge attributes from graph parameters g : networkx graph name : string attribute name returns dictionary of attributes keyed by edge .