标签: python graph networkx
我在Python中使用networkx库。
networkx中有一个名为connected_components(G)的函数,它输出图G中连接组件的列表。
请提供networkx库的此功能的源代码实现。
我不需要Pseudocode,我需要使用networkx库和Python的这个函数的源代码实现
答案 0 :(得分:0)
此函数的源代码(减去docstring)是:
def connected_components(G): seen = set() for v in G: if v not in seen: c = set(_plain_bfs(G, v)) yield c seen.update(c)
可以找到(包括docstring)here。
只需单击此功能的文档页面上的绿色[source]链接即可到达(如果您对将来的任何其他功能的源代码感兴趣,也可以使用此链接)。可以在here找到此特定功能的文档页面。
[source]