dfs_postorder_nodes#

dfs_postorder_nodes(G, source=None, depth_limit=None)[源代码]#

从源代码开始,在深度优先搜索后排序中生成节点。

参数
G网络X图表
source节点,可选

指定深度优先搜索的起始节点。

depth_limit整型,可选(默认值=len(G))

指定最大搜索深度。

返回
节点:生成器

深度优先搜索后排序中的节点生成器。

笔记

如果没有指定源,则可以任意地重复选择源,直到搜索到图中的所有组件。

该函数的实现是根据David Eppstein在 PADS 根据维基百科文章“深度限制搜索”进行修改以允许深度限制。

实例

>>> G = nx.path_graph(5)
>>> list(nx.dfs_postorder_nodes(G, source=0))
[4, 3, 2, 1, 0]
>>> list(nx.dfs_postorder_nodes(G, source=0, depth_limit=2))
[1, 0]