def edge_betweenness_centrality(G, k=None, normalized=True, weight=None, seed=None):
 betweenness = dict.fromkeys(G, 0.0)
 betweenness.update(dict.fromkeys(G.edges(), 0.0))
 if (k is None):
  nodes = G
 else:
  random.seed(seed)
  nodes = random.sample(G.nodes(), k)
 for s in nodes:
  if (weight is None):
   (S, P, sigma) = _single_source_shortest_path_basic(G, s)
  else:
   (S, P, sigma) = _single_source_dijkstra_path_basic(G, s, weight)
  betweenness = _accumulate_edges(betweenness, S, P, sigma, s)
 for n in G:
  del betweenness[n]
 betweenness = _rescale_e(betweenness, len(G), normalized=normalized, directed=G.is_directed())
 return betweenness

def edge_betweenness_centrality ( G , k = None , normalized = True , weight = None , seed = None ) : betweenness = dict . fromkeys ( G , 0.0 ) betweenness . update ( dict . fromkeys ( G . edges ( ) , 0.0 ) ) if ( k is None ) : nodes = G else : random . seed ( seed ) nodes = random . sample ( G . nodes ( ) , k ) for s in nodes : if ( weight is None ) : ( S , P , sigma ) = _single_source_shortest_path_basic ( G , s ) else : ( S , P , sigma ) = _single_source_dijkstra_path_basic ( G , s , weight ) betweenness = _accumulate_edges ( betweenness , S , P , sigma , s ) for n in G : del betweenness [ n ] betweenness = _rescale_e ( betweenness , len ( G ) , normalized = normalized , directed = G . is_directed ( ) ) return betweenness
compute betweenness centrality for edges .