#NEWLINE# def test_iterators( self ) : #NEWLINE# #INDENT# G = self . G ( ) #NEWLINE# G . add_edges_from ( [ ( 'A' , 'B' ) , ( 'A' , 'C' ) , ( 'B' , 'D' ) , ( 'C' , 'B' ) , ( 'C' , 'D' ) ] ) #NEWLINE# G . add_nodes_from ( 'GJK' ) #NEWLINE# assert_equal ( sorted ( G . nodes ( ) ) , [ 'A' , 'B' , 'C' , 'D' , 'G' , 'J' , 'K' ] ) #NEWLINE# assert_edges_equal ( G . edges ( ) , [ ( 'A' , 'B' ) , ( 'A' , 'C' ) , ( 'B' , 'D' ) , ( 'C' , 'B' ) , ( 'C' , 'D' ) ] ) #NEWLINE# assert_equal ( sorted ( [ v for ( k , v ) in G . degree ( ) ] ) , [ 0 , 0 , 0 , 2 , 2 , 3 , 3 ] ) #NEWLINE# assert_equal ( sorted ( G . degree ( ) , key = str ) , [ ( 'A' , 2 ) , ( 'B' , 3 ) , ( 'C' , 3 ) , ( 'D' , 2 ) , ( 'G' , 0 ) , ( 'J' , 0 ) , ( 'K' , 0 ) ] ) #NEWLINE# assert_equal ( sorted ( G . neighbors ( 'A' ) ) , [ 'B' , 'C' ] ) #NEWLINE# assert_raises ( nx . NetworkXError , G . neighbors , 'X' ) #NEWLINE# G . clear ( ) #NEWLINE# assert_equal ( nx . number_of_nodes ( G ) , 0 ) #NEWLINE# assert_equal ( nx . number_of_edges ( G ) , 0 )