public TopologicalSortShortestPath(WeightedDiGraph G, int s) { this.s = s; int V = G.V(); marked = new bool[V]; edgeTo = new Edge[V]; cost = new double[V]; for (var i = 0; i < V; ++i) { cost[i] = Double.MaxValue; } cost[s] = 0; DepthFirstPostOrder dfo = new DepthFirstPostOrder(G.ToDiGraph()); foreach (var v in dfo.PostOrder()) { foreach (var e in G.adj(v)) { Relax(G, e); } } }