public AcyclicSP(EdgeWeightedDigraph g, int s) { this._g = g; this._s = s; this.DistTo = new double[g.V()]; this._edgeTo = new DirectedEdge[g.V()]; for (int v = 0; v < g.V(); v++) this.DistTo[v] = double.PositiveInfinity; this.DistTo[s] = 0d; Topological top = new Topological(g); foreach (int v in top.Order) foreach (DirectedEdge e in g.Adj[v]) this.relax(e); }
public AcyclicLP(EdgeWeightedDigraph g, int s) { this._g = g; this._s = s; this.DistTo = new double[g.V()]; this._edgeTo = new DirectedEdge[g.V()]; for (int v = 0; v < g.V(); v++) this.DistTo[v] = double.NegativeInfinity; this.DistTo[s] = 0d; Topological top = new Topological(g); if (top.Order == null) throw new Exception("Digraph is not acyclic."); foreach (int v in top.Order) foreach (DirectedEdge e in g.Adj[v]) this.relax(e); }