

def test_topological_sort1(self):
    DG = nx.DiGraph()
    DG.add_edges_from([(1, 2), (1, 3), (2, 3)])
    assert_equal(nx.topological_sort(DG), [1, 2, 3])
    assert_equal(nx.topological_sort_recursive(DG), [1, 2, 3])
    DG.add_edge(3, 2)
    assert_raises(nx.NetworkXUnfeasible, nx.topological_sort, DG)
    assert_raises(nx.NetworkXUnfeasible, nx.topological_sort_recursive, DG)
    DG.remove_edge(2, 3)
    assert_equal(nx.topological_sort(DG), [1, 3, 2])
    assert_equal(nx.topological_sort_recursive(DG), [1, 3, 2])

dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/tests/test_dag.py TestDAG.test_topological_sort1/original