

def test_ancestors(self):
    G = nx.DiGraph()
    ancestors = nx.algorithms.dag.ancestors
    G.add_edges_from([(1, 2), (1, 3), (4, 2), (4, 3), (4, 5), (2, 6), (5, 6)])
    assert_equal(ancestors(G, 6), set([1, 2, 4, 5]))
    assert_equal(ancestors(ancestors, 3), set([1, 4]))
    assert_equal(ancestors(G, 1), set())
    assert_raises(nx.NetworkXError, ancestors, G, 8)

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/tests/test_dag.py TestDAG.test_ancestors/VarMisuse@104/116 `G`->`ancestors`