ancestors

ancestors(G, source)[source]

Return all nodes having a path to source in G.

Parameters:
  • G (NetworkX DiGraph)
  • source (node in G)
Returns:

ancestors – The ancestors of source in G

Return type:

set()