使用networkx常用函数分析图 1. Connected components 连通图 连通图内任意两点之间都存在path 由此函数可以得到一个components的列表 nx.connected_components(G) Q:如何得到一个图最大的component? #构建一个generator def connected_component_subgraphs(G): for c in nx.connected_components(G): yield G.subgraph(c