@not_implemented_for('directed')
@not_implemented_for('multigraph')
def ra_index_soundarajan_hopcroft(G, ebunch=None, community='community'):
 def predict(u, v):
  Cu = _community(G, u, community)
  Cv = _community(G, v, community)
  if (Cu != Cv):
   return 0
  cnbors = nx.common_neighbors(G, u, v)
  return sum(((1 / G.degree(w)) for w in cnbors if (_community(G, w, community) == Cu)))
 return _apply_prediction(G, predict, ebunch)

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def ra_index_soundarajan_hopcroft ( G , ebunch = None , community = 'community' ) : def predict ( u , v ) : Cu = _community ( G , u , community ) Cv = _community ( G , v , community ) if ( Cu != Cv ) : return 0 cnbors = nx . common_neighbors ( G , u , v ) return sum ( ( ( 1 / G . degree ( w ) ) for w in cnbors if ( _community ( G , w , community ) == Cu ) ) ) return _apply_prediction ( G , predict , ebunch )
compute the resource allocation index of all node pairs in ebunch using community information .