Skip to content

Commit d67992a

Browse files
Addressing review comments (And fixing a bug)
Co-authored-by: Veselin Nikolov <veselin.nikolov@neotechnology.com>
1 parent 8ed3f6a commit d67992a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

algo/src/main/java/org/neo4j/gds/steiner/SteinerBasedDeltaStepping.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
public final class SteinerBasedDeltaStepping extends Algorithm<DijkstraResult> {
5959

6060
public static final int NO_BIN = Integer.MAX_VALUE;
61+
62+
private static final long NO_TERMINAL = -1;
6163
public static final int BIN_SIZE_THRESHOLD = 1000;
6264
private final Graph graph;
6365
private final long startNode;
@@ -144,7 +146,7 @@ private void syncPhase(List<SteinerBasedDeltaTask> tasks,int currentBin, AtomicL
144146
}
145147

146148
private long nextTerminal(HugeLongPriorityQueue terminalQueue) {
147-
return (terminalQueue.isEmpty()) ? -1 : terminalQueue.top();
149+
return (terminalQueue.isEmpty()) ? NO_TERMINAL : terminalQueue.top();
148150
}
149151

150152
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
183185
//For the moment, we use a simple criteria to discover if there is a terminal for which with full certainty,
184186
//we have found a shortest to it: Whenever we change from one bin to another, we find the terminal of smallest distance
185187
//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) {
187189
shouldComputeClosestTerminal = true;
188190
}
189191
if (shouldComputeClosestTerminal) {
190192
long terminalId = nextTerminal(terminalQueue);
191-
if (terminalId == -1) return -1;
193+
if (terminalId == NO_TERMINAL) return NO_TERMINAL;
192194
if (distances.distance(terminalId) < currentBin * delta) {
193195
return terminalId;
194196
}

0 commit comments

Comments
 (0)