@not_implemented_for('directed')
@not_implemented_for('multigraph')
def within_inter_cluster(G, ebunch=None, delta=0.001, community='community'):
 if (delta <= 0):
  raise nx.NetworkXAlgorithmError('Delta must be greater than zero')
 def predict(u, v):
  Cu = _community(G, u, community)
  Cv = _community(G, v, community)
  if (Cu != Cv):
   return 0
  cnbors = set(nx.common_neighbors(G, u, v))
  within = set((w for w in cnbors if (_community(G, w, community) == Cu)))
  inter = (cnbors - within)
  return (len(within) / (len(inter) + delta))
 return _apply_prediction(G, predict, ebunch)

@ not_implemented_for ( 'directed' ) @ not_implemented_for ( 'multigraph' ) def within_inter_cluster ( G , ebunch = None , delta = 0.001 , community = 'community' ) : if ( delta <= 0 ) : raise nx . NetworkXAlgorithmError ( 'Delta must be greater than zero' ) def predict ( u , v ) : Cu = _community ( G , u , community ) Cv = _community ( G , v , community ) if ( Cu != Cv ) : return 0 cnbors = set ( nx . common_neighbors ( G , u , v ) ) within = set ( ( w for w in cnbors if ( _community ( G , w , community ) == Cu ) ) ) inter = ( cnbors - within ) return ( len ( within ) / ( len ( inter ) + delta ) ) return _apply_prediction ( G , predict , ebunch )
compute the ratio of within- and inter-cluster common neighbors of all node pairs in ebunch .