public EWDGraphTopological(EdgeWeightDigraph G) { EdgeWeightedCycle cycleFind = new EdgeWeightedCycle(G); if (!cycleFind.HasCycle()) { DFOrder dfs = new DFOrder(G); order = dfs.ReversePost(); } }
private IEnumerable <int> order; //顶点的拓扑顺序 public Topological(DiGraph G) { DirectedCycle cyclefind = new DirectedCycle(G); if (!cyclefind.hasCycle()) { //这里是核心,使用了DFOrder 类 中的 逆后序方法 //一幅 有向无环图 的拓扑顺序 即为所有顶点的 逆后序排列 DFOrder dfs = new DFOrder(G); order = dfs.ReversePost(); } }