1# Option 1
2G = max(nx.connected_component_subgraphs(G), key=len)
3
4# Option 2
5for component in list(nx.connected_components(G)):
6 if len(component) < 16451: # Size of the largest component
7 for node in component:
8 G.remove_node(node)