descendants_at_distance#

descendants_at_distance(G, source, distance)[source]#

返回 G 中与 source 固定 distance 距离的所有节点。

Parameters:
GNetworkX 图

一个图

source :`G` 中的节点
distance所需节点与 source 的距离
Returns:
set()

G 中与 source 在给定 distance 距离的后代节点

Examples

>>> G = nx.path_graph(5)
>>> nx.descendants_at_distance(G, 2, 2)
{0, 4}
>>> H = nx.DiGraph()
>>> H.add_edges_from([(0, 1), (0, 2), (1, 3), (1, 4), (2, 5), (2, 6)])
>>> nx.descendants_at_distance(H, 0, 2)
{3, 4, 5, 6}
>>> nx.descendants_at_distance(H, 5, 0)
{5}
>>> nx.descendants_at_distance(H, 5, 1)
set()

Additional backends implement this function

graphblas : OpenMP-enabled sparse linear algebra backend.