is_connected (G)) True. [R167] On finding the strongly connected components in a directed graph. There, the components variable happens to be the last component in the graph (it's the last thing assigned to that loop variable), and you're printing out your total component count and time, which is the total component count and time for all components because of Issue #2. It is weakly connected if replacing all the edges of the directed graph with undirected edges will produce a Undirected Connected Graph. path_graph (4) >>> print (nx. G (NetworkX Graph) – An directed graph. G (NetworkX graph) – An undirected graph: Returns: comp – A generator of sets of nodes, one for each component of G. Return type: generator of sets: Raises: NetworkXNotImplemented: – If G is undirected. I have a directed graph G, created using networkX in Python. I have a working, but really inefficient-looking, snippet down: # G = nx.Graph() giant = sorted(nx.connected_component_subgraphs(G), key=len, reverse=True)[0] If you use the networkx output G from the first code block, max(nx.strongly_connected_components(G), key=len) will give an output with 126 nodes and 52xx something edges, but if you apply the one-liner I listed above, you will get: They can be checked by the following code: nx.is_strongly_connected(G) nx.is_weakly_connected(G) The given Directed Graph is weakly connected, not strongly connected. connected_components() Notes. Returns: comp – A generator of sets of nodes, one for each strongly connected component of G. Return type: generator of sets: Raises: NetworkXNotImplemented – If G is undirected. ; copy (bool (default=True)) – If True make a copy of the graph attributes; Returns: comp – A generator of graphs, one for each connected component of G.. Return type: generator. See also. Parameters: G (NetworkX graph) – An undirected graph. I have a certain list of nodes and I am trying to find the connected components within these nodes. Adding attributes to graphs, nodes, and edges; Directed graphs; Multigraphs; Graph generators and graph operations; Analyzing graphs ... (NetworkX Graph) – An undirected graph ... Return type: bool: Examples >>> G = nx. And we can implement .strongly_connected_components(G) and strongly_connected_subgraphs to verify. Below I have created a sample dataset (the actual graph I am dealing with is much larger). Depth-first search and linear graph algorithms, R. Tarjan SIAM Journal of Computing 1(2):146-160, (1972). Parameters: G (NetworkX graph) – An undirected graph. Each edge is bidirectional. Raises: NetworkXNotImplemented: – If G is undirected. : Returns: n – Number of connected components: Return type: integer As I understand connected_components() method in NetworkX should generate components in a given undirected graph (There are strongly_connected_components() and weakly_connected_components() for directed graph). I don't know if NetworkX recently tweaked one of the methods to be a generator instead of returning a list, but I'm looking for a good (rather, better) way to get the GC of a graph.