extract_largest_component#
- graph_tool.topology.extract_largest_component(g, directed=None, prune=False)[source]#
Extract the largest (strong) component in the graph as a
GraphView
(orGraph
ifprune==True
).If the graph is directed, then the largest strongly connected component is returned.
- Parameters:
- Returns:
Notes
The algorithm runs in \(O(V + E)\) time.
Examples
>>> g = gt.random_graph(100, lambda: poisson(1), directed=False) >>> u = gt.extract_largest_component(g) >>> print(u) <GraphView object, undirected, with 28 vertices and 27 edges, edges filtered by (<EdgePropertyMap object with value type 'bool', for Graph 0x..., at 0x...>, False), vertices filtered by (<VertexPropertyMap object with value type 'bool', for Graph 0x..., at 0x...>, False), at 0x...>