Weakly Connected Components in a Directed Graph

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]

Use a GraphView to obtain an undirected view of the graph, then run the algorithm. Ni!

Just use:

label_components(g, directed=False)

This is equivalent to what @solstag proposed, but is a bit more convenient.

Thankyou for the fast rely,

label_components with directed=False gives propertymap what I want.
(Was trying with directed=True because my graph is directed graph)

thanks for the awesome information.