pub fn topological_sort(
    n: usize,
    edges: &[(usize, usize)]
) -> Option<Vec<usize>>
Expand description

有向グラフの頂点をトポロジカル順に並べて返します。グラフが DAG でなければ None を返します。

Examples

use topological_sort::topological_sort;

let order = topological_sort(4, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
assert!(order == Some(vec![0, 1, 2, 3]) || order == Some(vec![0, 2, 1, 3]));