def edge_betweenness_centrality_subset(G, sources, targets, normalized=False, weight=None):
 b = dict.fromkeys(G, 0.0)
 b.update(dict.fromkeys(G.edges(), 0.0))
 for s in sources:
  if (weight is None):
   (S, P, sigma) = shortest_path(G, s)
  else:
   (S, P, sigma) = dijkstra(G, s, weight)
  b = _accumulate_edges_subset(b, S, P, sigma, s, targets)
 for n in G:
  del b[n]
 b = _rescale_e(b, len(G), normalized=normalized, directed=G.is_directed())
 return b

def edge_betweenness_centrality_subset ( G , sources , targets , normalized = False , weight = None ) : b = dict . fromkeys ( G , 0.0 ) b . update ( dict . fromkeys ( G . edges ( ) , 0.0 ) ) for s in sources : if ( weight is None ) : ( S , P , sigma ) = shortest_path ( G , s ) else : ( S , P , sigma ) = dijkstra ( G , s , weight ) b = _accumulate_edges_subset ( b , S , P , sigma , s , targets ) for n in G : del b [ n ] b = _rescale_e ( b , len ( G ) , normalized = normalized , directed = G . is_directed ( ) ) return b
compute betweenness centrality for edges for a subset of nodes .