Fixed graph relaxEdge to properly deal with Double.MIN_VALUE.
Showing
2 changed files
with
3 additions
and
3 deletions
| ... | @@ -108,7 +108,7 @@ public class PointToPointIntentCompiler | ... | @@ -108,7 +108,7 @@ public class PointToPointIntentCompiler |
| 108 | if (lt == Link.Type.OPTICAL) { | 108 | if (lt == Link.Type.OPTICAL) { |
| 109 | return 1000.0; | 109 | return 1000.0; |
| 110 | } else { | 110 | } else { |
| 111 | - return 1.0; | 111 | + return Double.MIN_VALUE; |
| 112 | } | 112 | } |
| 113 | } | 113 | } |
| 114 | }; | 114 | }; | ... | ... |
| ... | @@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
| 36 | public abstract class AbstractGraphPathSearch<V extends Vertex, E extends Edge<V>> | 36 | public abstract class AbstractGraphPathSearch<V extends Vertex, E extends Edge<V>> |
| 37 | implements GraphPathSearch<V, E> { | 37 | implements GraphPathSearch<V, E> { |
| 38 | 38 | ||
| 39 | - private double samenessThreshold = 0.000000001; | 39 | + private double samenessThreshold = Double.MIN_VALUE; |
| 40 | 40 | ||
| 41 | /** | 41 | /** |
| 42 | * Sets a new sameness threshold for comparing cost values; default is | 42 | * Sets a new sameness threshold for comparing cost values; default is |
| ... | @@ -183,7 +183,7 @@ public abstract class AbstractGraphPathSearch<V extends Vertex, E extends Edge<V | ... | @@ -183,7 +183,7 @@ public abstract class AbstractGraphPathSearch<V extends Vertex, E extends Edge<V |
| 183 | 183 | ||
| 184 | double newCost = cost + hopCost; | 184 | double newCost = cost + hopCost; |
| 185 | boolean relaxed = newCost < oldCost; | 185 | boolean relaxed = newCost < oldCost; |
| 186 | - boolean same = Math.abs(newCost - oldCost) < samenessThreshold; | 186 | + boolean same = Math.abs(newCost - oldCost) <= samenessThreshold; |
| 187 | if (same || relaxed) { | 187 | if (same || relaxed) { |
| 188 | updateVertex(v, e, newCost, !same); | 188 | updateVertex(v, e, newCost, !same); |
| 189 | } | 189 | } | ... | ... |
-
Please register or login to post a comment