#NEWLINE# def test_weighted_graph( self ) : #NEWLINE# #INDENT# eList = [ ( 0 , 1 , 5 ) , ( 0 , 2 , 4 ) , ( 0 , 3 , 3 ) , ( 0 , 4 , 2 ) , ( 1 , 2 , 4 ) , ( 1 , 3 , 1 ) , ( 1 , 4 , 3 ) , ( 2 , 4 , 5 ) , ( 3 , 4 , 4 ) ] #NEWLINE# G = nx . Graph ( ) #NEWLINE# G . add_weighted_edges_from ( eList ) #NEWLINE# b = nx . edge_betweenness_centrality ( G , weight = 'weight' , normalized = False ) #NEWLINE# b_answer = { #NEWLINE# #INDENT# ( 0 , 1 ) : 0.0 , #NEWLINE# ( 0 , 2 ) : 1.0 , #NEWLINE# ( 0 , 3 ) : 2.0 , #NEWLINE# ( 0 , 4 ) : 1.0 , #NEWLINE# ( 1 , 2 ) : 2.0 , #NEWLINE# ( 1 , 3 ) : 3.5 , #NEWLINE# ( 1 , 4 ) : 1.5 , #NEWLINE# ( 2 , 4 ) : 1.0 , #NEWLINE# ( 3 , 4 ) : 0.5 , #NEWLINE# #UNINDENT# } #NEWLINE# for n in sorted ( G . edges ( ) ) : #NEWLINE# #INDENT# assert_almost_equal ( b [ n ] , b_answer [ n ] )