#NEWLINE# def test_K5( self ) : #NEWLINE# #INDENT# 'Katz centrality: K5' #NEWLINE# G = networkx . complete_graph ( 5 ) #NEWLINE# alpha = 0.1 #NEWLINE# b = networkx . katz_centrality ( G , alpha ) #NEWLINE# v = math . sqrt ( ( 1 / 5.0 ) ) #NEWLINE# b_answer = dict . fromkeys ( G , v ) #NEWLINE# for n in sorted ( G ) : #NEWLINE# #INDENT# assert_almost_equal ( b [ n ] , b_answer [ n ] ) #NEWLINE# #UNINDENT# nstart = dict ( [ ( nstart , 1 ) for n in G ] ) #NEWLINE# b = networkx . eigenvector_centrality_numpy ( G ) #NEWLINE# for n in sorted ( G ) : #NEWLINE# #INDENT# assert_almost_equal ( b [ n ] , b_answer [ n ] , places = 3 )