private void relax(DirectedEdge e) { int v = e.From(), w = e.To(); if (this.DistTo[w] > this.DistTo[v] + e.Weight()) { this.DistTo[w] = this.DistTo[v] + e.Weight(); this._edgeTo[w] = e; } }
private void relax(DirectedEdge e) { int v = e.From(), w = e.To(); if (this.DistTo[w] > this.DistTo[v] + e.Weight()) { this.DistTo[w] = this.DistTo[v] + e.Weight(); this._edgeTo[w] = e; if (this._pq.Contains(w)) this._pq.DecreaseKey(w, this.DistTo[w]); else this._pq.Insert(w, this.DistTo[w]); } }