Example #1
0
        private void Relax(DirectedWeightedEdge edge, int target)
        {
            var u = edge.To();
            var v = edge.From();

            if (distTo[u] > distTo[v] + edge.Weight())
            {
                distTo[u] = distTo[v] + edge.Weight();
                edgeTo[u] = edge;

                if (pq.Contains(u))
                {
                    pq.DecreaseKey(u, heuristic(target, u) + distTo[u]);
                }
                else
                {
                    pq.Insert(u, heuristic(target, u) + distTo[u]);
                }
            }
        }