#NEWLINE# def test_bipartite_density( self ) : #NEWLINE# #INDENT# G = nx . path_graph ( 5 ) #NEWLINE# ( X , Y ) = bipartite . sets ( self ) #NEWLINE# density = ( float ( len ( G . edges ( ) ) ) / ( len ( X ) * len ( Y ) ) ) #NEWLINE# assert_equal ( bipartite . density ( G , X ) , density ) #NEWLINE# D = nx . DiGraph ( G . edges ( ) ) #NEWLINE# assert_equal ( bipartite . density ( D , X ) , ( density / 2.0 ) ) #NEWLINE# assert_equal ( bipartite . density ( nx . Graph ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) , 0.0 )