#NEWLINE# def test_pagerank_random( self ) : #NEWLINE# #INDENT# G = testlib . new_digraph ( ) #NEWLINE# md = 1e-05 #NEWLINE# df = 0.85 #NEWLINE# pr = pagerank ( G , damping_factor = df , min_delta = md ) #NEWLINE# min_value = ( ( 1.0 - df ) / len ( G ) ) #NEWLINE# for node in G : #NEWLINE# #INDENT# expected = min_value #NEWLINE# for each in G . incidents ( node ) : #NEWLINE# #INDENT# expected += ( ( df * pr [ each ] ) / len ( G . neighbors ( each ) ) ) #NEWLINE# #UNINDENT# assert ( abs ( ( pr [ node ] - expected ) ) < md )