is_connected (G)) True. G (NetworkX Graph) – An directed graph. 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. And we can implement .strongly_connected_components(G) and strongly_connected_subgraphs to verify. I have a directed graph G, created using networkX in Python. 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. I have a certain list of nodes and I am trying to find the connected components within these nodes. 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). 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. 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: Below I have created a sample dataset (the actual graph I am dealing with is much larger). 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. Parameters: G (NetworkX graph) – An undirected graph. : Returns: n – Number of connected components: Return type: integer Each edge is bidirectional. Parameters: G (NetworkX graph) – An undirected graph. path_graph (4) >>> print (nx. 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] ; 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. Raises: NetworkXNotImplemented: – If G is undirected. Depth-first search and linear graph algorithms, R. Tarjan SIAM Journal of Computing 1(2):146-160, (1972). 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. It is weakly connected if replacing all the edges of the directed graph with undirected edges will produce a Undirected Connected Graph. [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.