You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/06/22 01:38:54 UTC

svn commit: r1138248 - /commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java

Author: simonetripodi
Date: Tue Jun 21 23:38:53 2011
New Revision: 1138248

URL: http://svn.apache.org/viewvc?rev=1138248&view=rev
Log:
stored the hScore value in a tmp variable

Modified:
    commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java

Modified: commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java
URL: http://svn.apache.org/viewvc/commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java?rev=1138248&r1=1138247&r2=1138248&view=diff
==============================================================================
--- commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java (original)
+++ commons/sandbox/graph/trunk/src/main/java/org/apache/commons/graph/shortestpath/AStar.java Tue Jun 21 23:38:53 2011
@@ -68,7 +68,8 @@ public final class AStar
 
         // Estimated total cost from start to goal through y.
         final ShortestDistances<V> fScores = new ShortestDistances<V>();
-        fScores.setWeight( start, heuristic.applyHeuristic( start, goal ) );
+        Double hScore = heuristic.applyHeuristic( start, goal );
+        fScores.setWeight( start, hScore );
 
         // The set of nodes already evaluated.
         final Set<V> closedSet = new HashSet<V>();
@@ -109,7 +110,8 @@ public final class AStar
                     {
                         predecessors.addPredecessor( v, edge );
                         gScores.setWeight( v, tentativeGScore );
-                        fScores.setWeight( v, gScores.getWeight( v ) + heuristic.applyHeuristic( v, goal ) );
+                        hScore = heuristic.applyHeuristic( v, goal );
+                        fScores.setWeight( v, gScores.getWeight( v ) + hScore );
                     }
                 }
             }