How to Find Weakly Connected Components in a Directed Graph with graph-tool.

Given a directed graph, a weakly connected component (WCC) is a subgraph of the original graph where all vertices are connected to each other by some path, ignoring the direction of edges.

“graph_tool.topology.label_components” is simmial to what I want to do, but it finds the strongly connected components.

I want to replace networkx code bellow with graph-tools

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

G.add_path([10, 11, 12])

[len(c) for c in sorted(nx.weakly_connected_components(G), … key=len, reverse=True)]

[4, 3]