// relax edge e and update pq if changed private void relax(DirectedEdge e) { int v = e.from(), w = e.to(); if (_distTo[w] > _distTo[v] + e.weight()) { _distTo[w] = _distTo[v] + e.weight(); edgeTo[w] = e; if (pq.Contains(w)) pq.DecreaseKey(w, _distTo[w]); else pq.Insert(w, _distTo[w]); } }
/** * Adds the directed edge <tt>e</tt> to the edge-weighted digraph. * @param e the edge */ public void addEdge(DirectedEdge e) { int v = e.from(); _adj[v].Add(e); _E++; }