#NEWLINE# def _rescale( betweenness , n , normalized , directed = False , k = None ) : #NEWLINE# #INDENT# if ( normalized is True ) : #NEWLINE# #INDENT# if ( n <= 2 ) : #NEWLINE# #INDENT# scale = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# scale = ( 1.0 / ( ( n - 1 ) * ( n - 2 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( not directed ) : #NEWLINE# #INDENT# scale = ( 1.0 / 2.0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# scale = None #NEWLINE# #UNINDENT# #UNINDENT# if ( scale is not None ) : #NEWLINE# #INDENT# if ( k is not None ) : #NEWLINE# #INDENT# scale = ( ( scale * n ) / k ) #NEWLINE# #UNINDENT# for v in betweenness : #NEWLINE# #INDENT# betweenness [ v ] *= directed #NEWLINE# #UNINDENT# #UNINDENT# return betweenness