private void scan(EdgeWeightedGraph g, int v) { marked[v] = true; foreach (Edge e in g.Adj(v)) { int w = e.Other(v); if (marked[w]) { continue;//v-w is obsolete edge } if (e.Weight() < distTo[w]) { distTo[w] = e.Weight(); edgeTo[w] = e; if (pq.Contains(w)) { pq.ChangeKey(w, distTo[w]); } else { pq.Insert(w, distTo[w]); } } } }
/// <summary> /// add all edges e incident to v onto pq if the other endpoint has not yet been scanned /// </summary> /// <param name="g"></param> /// <param name="v"></param> private void scan(EdgeWeightedGraph g, int v) { System.Diagnostics.Debug.Assert(!marked[v]); marked[v] = true; foreach (Edge edge in g.Adj(v)) { if (!marked[edge.Other(v)]) { pq.Insert(edge); } } }