<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class Solution ( object ) : <EOL> def countComponents ( self , n , edges ) : <EOL> """<STR_LIT>""" <EOL> V = [ [ ] for _ in xrange ( n ) ] <EOL> for e in edges : <EOL> V [ e [ <NUM_LIT:0> ] ] . append ( e [ <NUM_LIT:1> ] ) <EOL> V [ e [ <NUM_LIT:1> ] ] . append ( e [ <NUM_LIT:0> ] ) <EOL> visited = [ False for _ in xrange ( n ) ] <EOL> cnt = <NUM_LIT:0> <EOL> for v in xrange ( n ) : <EOL> if not visited [ v ] : <EOL> cnt += <NUM_LIT:1> <EOL> self . dfs ( V , v , visited ) <EOL> return cnt <EOL> def dfs ( self , V , v , visited ) : <EOL> visited [ v ] = True <EOL> for nbr in V [ v ] : <EOL> if not visited [ nbr ] : <EOL> self . dfs ( V , nbr , visited ) </s>
