# networkx.algorithms.components.weakly_connected_components¶

weakly_connected_components(G)[source]

Generate weakly connected components of G.

Parameters

G (NetworkX graph) – A directed graph

Returns

comp – A generator of sets of nodes, one for each weakly connected component of G.

Return type

generator of sets

Raises

NetworkXNotImplemented – If G is undirected.

Examples

Generate a sorted list of weakly connected components, largest first.

>>> G = nx.path_graph(4, create_using=nx.DiGraph())

>>> largest_cc = max(nx.weakly_connected_components(G), key=len)