def _edge_value(G, edge_attr):
 if (edge_attr is None):
  if G.is_multigraph():
   value = (lambda u, v: len(G[u][v]))
  else:
   value = (lambda u, v: 1)
 elif (not hasattr(edge_attr, '__call__')):
  if (edge_attr == 'weight'):
   if G.is_multigraph():
    value = (lambda u, v: sum([d.get(edge_attr, 1) for d in G[u][v].values()]))
   else:
    value = (lambda u, v: G[u][v].get(edge_attr, 1))
  elif G.is_multigraph():
   value = (lambda u, v: sum([d[edge_attr] for d in G[u][v].values()]))
  else:
   value = (lambda u, v: G[u][v][edge_attr])
 else:
  value = edge_attr
 return value

def _edge_value ( G , edge_attr ) : if ( edge_attr is None ) : if G . is_multigraph ( ) : value = ( lambda u , v : len ( G [ u ] [ v ] ) ) else : value = ( lambda u , v : 1 ) elif ( not hasattr ( edge_attr , '__call__' ) ) : if ( edge_attr == 'weight' ) : if G . is_multigraph ( ) : value = ( lambda u , v : sum ( [ d . get ( edge_attr , 1 ) for d in G [ u ] [ v ] . values ( ) ] ) ) else : value = ( lambda u , v : G [ u ] [ v ] . get ( edge_attr , 1 ) ) elif G . is_multigraph ( ) : value = ( lambda u , v : sum ( [ d [ edge_attr ] for d in G [ u ] [ v ] . values ( ) ] ) ) else : value = ( lambda u , v : G [ u ] [ v ] [ edge_attr ] ) else : value = edge_attr return value
returns a function that returns a value from g[u][v] .