@not_implemented_for('directed')
@not_implemented_for('multigraph')
def cn_soundarajan_hopcroft(G, ebunch=None, community='community'):
 def predict(u, v):
  Cu = _community(G, u, community)
  Cv = _community(G, v, community)
  cnbors = list(nx.common_neighbors(G, u, v))
  neighbors = (sum(((_community(G, w, community) == Cu) for w in cnbors)) if (Cu == Cv) else 0)
  return (len(cnbors) + neighbors)
 return _apply_prediction(G, predict, ebunch)

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def cn_soundarajan_hopcroft ( G , ebunch = None , community = 'community' ) : def predict ( u , v ) : Cu = _community ( G , u , community ) Cv = _community ( G , v , community ) cnbors = list ( nx . common_neighbors ( G , u , v ) ) neighbors = ( sum ( ( ( _community ( G , w , community ) == Cu ) for w in cnbors ) ) if ( Cu == Cv ) else 0 ) return ( len ( cnbors ) + neighbors ) return _apply_prediction ( G , predict , ebunch )
count the number of common neighbors of all node pairs in ebunch using community information .