From 0c7ff7ecc4c9f76bb4eab4d79c71e36cba8b1f7c Mon Sep 17 00:00:00 2001 From: ioannispan Date: Wed, 31 Jul 2024 12:58:52 +0200 Subject: [PATCH] minors Co-authored-by: Veselin Nikolov --- algo/src/main/java/org/neo4j/gds/paths/yens/YensTask.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/algo/src/main/java/org/neo4j/gds/paths/yens/YensTask.java b/algo/src/main/java/org/neo4j/gds/paths/yens/YensTask.java index 9668cb0410..2e2714b197 100644 --- a/algo/src/main/java/org/neo4j/gds/paths/yens/YensTask.java +++ b/algo/src/main/java/org/neo4j/gds/paths/yens/YensTask.java @@ -107,9 +107,7 @@ private void process(int indexId) { var spurPath = computeDijkstra(spurNode); // No new candidate from this spur node, continue with next node. - if (spurPath.isPresent()) { - storePath(indexId, rootPath, spurPath); - } + spurPath.ifPresent(pathResult -> storePath(indexId, rootPath, pathResult)); } @@ -137,10 +135,10 @@ private Optional computeDijkstra(long spurNode) { return localDijkstra.compute().findFirst(); } - private void storePath(int indexId, MutablePathResult rootPath, Optional spurPath) { + private void storePath(int indexId, MutablePathResult rootPath, PathResult spurPath) { // Entire path is made up of the root path and spur path. - pathAppender.accept(rootPath, spurPath.get()); + pathAppender.accept(rootPath, spurPath); //https://en.wikipedia.org/wiki/Yen%27s_algorithm#Lawler's_modification //We store the index of the spur node