|
58 | 58 | public final class SteinerBasedDeltaStepping extends Algorithm<DijkstraResult> { |
59 | 59 |
|
60 | 60 | public static final int NO_BIN = Integer.MAX_VALUE; |
| 61 | + |
| 62 | + private static final long NO_TERMINAL = -1; |
61 | 63 | public static final int BIN_SIZE_THRESHOLD = 1000; |
62 | 64 | private final Graph graph; |
63 | 65 | private final long startNode; |
@@ -144,7 +146,7 @@ private void syncPhase(List<SteinerBasedDeltaTask> tasks,int currentBin, AtomicL |
144 | 146 | } |
145 | 147 |
|
146 | 148 | private long nextTerminal(HugeLongPriorityQueue terminalQueue) { |
147 | | - return (terminalQueue.isEmpty()) ? -1 : terminalQueue.top(); |
| 149 | + return (terminalQueue.isEmpty()) ? NO_TERMINAL : terminalQueue.top(); |
148 | 150 | } |
149 | 151 |
|
150 | 152 | private boolean updateSteinerTree(long terminalId,AtomicLong frontierIndex,List<PathResult> paths, ImmutablePathResult.Builder pathResultBuilder) { |
@@ -183,12 +185,12 @@ private long tryToUpdateSteinerTree(long oldBin, long currentBin, HugeLongPriori |
183 | 185 | //For the moment, we use a simple criteria to discover if there is a terminal for which with full certainty, |
184 | 186 | //we have found a shortest to it: Whenever we change from one bin to another, we find the terminal of smallest distance |
185 | 187 | //if it's distance is below the currentBin, the path to it is optimal. |
186 | | - if (currentBin == -1 || oldBin < currentBin) { |
| 188 | + if (currentBin == NO_BIN || oldBin < currentBin) { |
187 | 189 | shouldComputeClosestTerminal = true; |
188 | 190 | } |
189 | 191 | if (shouldComputeClosestTerminal) { |
190 | 192 | long terminalId = nextTerminal(terminalQueue); |
191 | | - if (terminalId == -1) return -1; |
| 193 | + if (terminalId == NO_TERMINAL) return NO_TERMINAL; |
192 | 194 | if (distances.distance(terminalId) < currentBin * delta) { |
193 | 195 | return terminalId; |
194 | 196 | } |
|
0 commit comments