@not_implemented_for('directed')
def connected_components(G):
 seen = set()
 for v in G:
  if (v not in seen):
   c = set(_plain_bfs(G, v))
   (yield c)
   seen.update(c)

@ not_implemented_for ( 'directed' ) def connected_components ( G ) : seen = set ( ) for v in G : if ( v not in seen ) : c = set ( _plain_bfs ( G , v ) ) ( yield c ) seen . update ( c )
generate connected components .