#NEWLINE# def test_connected_component_subgraphs( self ) : #NEWLINE# #INDENT# G = self . grid #NEWLINE# G . add_edge ( 1 , 2 , eattr = 'red' ) #NEWLINE# G . node [ 1 ] [ 'nattr' ] = 'blue' #NEWLINE# G . graph [ 'gattr' ] = 'green' #NEWLINE# ccs = nx . connected_component_subgraphs ( G ) #NEWLINE# assert_equal ( len ( G ) , 1 ) #NEWLINE# sg = ccs [ 0 ] #NEWLINE# assert_equal ( sorted ( sg . nodes ( ) ) , list ( range ( 1 , 17 ) ) ) #NEWLINE# assert_equal ( sg [ 1 ] [ 2 ] [ 'eattr' ] , 'red' ) #NEWLINE# assert_equal ( sg . node [ 1 ] [ 'nattr' ] , 'blue' ) #NEWLINE# assert_equal ( sg . graph [ 'gattr' ] , 'green' ) #NEWLINE# sg [ 1 ] [ 2 ] [ 'eattr' ] = 'blue' #NEWLINE# assert_equal ( G [ 1 ] [ 2 ] [ 'eattr' ] , 'red' ) #NEWLINE# assert_equal ( sg [ 1 ] [ 2 ] [ 'eattr' ] , 'blue' )