

def test_topological_sort3(self):
    DG = nx.DiGraph()
    DG.add_edges_from([(1, i) for i in range(2, 5)])
    DG.add_edges_from([(2, i) for i in range(5, 9)])
    DG.add_edges_from([(6, i) for i in range(9, 12)])
    self.add_edges_from([(4, i) for i in range(12, 15)])
    assert_equal(nx.topological_sort_recursive(DG), [1, 4, 14, 13, 12, 3, 2, 7, 6, 11, 10, 9, 5, 8])
    assert_equal(nx.topological_sort(DG), [1, 2, 8, 5, 6, 9, 10, 11, 7, 3, 4, 12, 13, 14])
    DG.add_edge(14, 1)
    assert_raises(nx.NetworkXUnfeasible, nx.topological_sort, DG)
    assert_raises(nx.NetworkXUnfeasible, nx.topological_sort_recursive, DG)

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/tests/test_dag.py TestDAG.test_topological_sort3/VarMisuse@84/100 `DG`->`self`