From bd65f8556a79d92e02a8b72059b2ec017d2c9aba Mon Sep 17 00:00:00 2001 From: zyxxoo <1318247699@qq.com> Date: Tue, 27 Apr 2021 16:47:46 +0800 Subject: [PATCH 1/3] Fix Integer case Double failed --- .../algorithm/SingleSourceShortestPathTraverser.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java index cbe69c9ca5..889007c142 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java @@ -212,11 +212,19 @@ private double edgeWeight(HugeEdge edge) { !edge.property(this.weight).isPresent()) { edgeWeight = 1.0; } else { - edgeWeight = edge.value(this.weight); + edgeWeight = toDouble(edge.value(this.weight)); } return edgeWeight; } + private double toDouble(Object obj) { + if (obj instanceof Number) { + return ((Number) obj).doubleValue(); + } + + return (double) obj; + } + private Iterator skipSuperNodeIfNeeded(Iterator edges) { if (this.skipDegree <= 0L) { return edges; From 088d2a8ff3a687fea3d023a71b7b1a8989ead287 Mon Sep 17 00:00:00 2001 From: zyxxoo <1318247699@qq.com> Date: Tue, 27 Apr 2021 17:33:41 +0800 Subject: [PATCH 2/3] optimization error hint for top range --- .../hugegraph/traversal/algorithm/NeighborRankTraverser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java index f9060cb692..b1f46c19db 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java @@ -244,7 +244,7 @@ public static class Step { public Step(HugeGraph g, Directions direction, List labels, long degree, long skipDegree, int top, int capacity) { E.checkArgument(top > 0 && top <= MAX_TOP, - "The top of each layer can't exceed %s", MAX_TOP); + "The top of each layer muse be in (0, %s]", MAX_TOP); E.checkArgument(capacity > 0, "The capacity of each layer must be > 0, " + "but got %s", capacity); From 2473a219a5ebc7bd8302f9e2830c6f21181e0c86 Mon Sep 17 00:00:00 2001 From: zyxxoo <1318247699@qq.com> Date: Wed, 28 Apr 2021 12:06:48 +0800 Subject: [PATCH 3/3] Fix codeStyle --- .../hugegraph/traversal/algorithm/NeighborRankTraverser.java | 3 ++- .../traversal/algorithm/SingleSourceShortestPathTraverser.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java index b1f46c19db..68fd791863 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/NeighborRankTraverser.java @@ -244,7 +244,8 @@ public static class Step { public Step(HugeGraph g, Directions direction, List labels, long degree, long skipDegree, int top, int capacity) { E.checkArgument(top > 0 && top <= MAX_TOP, - "The top of each layer muse be in (0, %s]", MAX_TOP); + "The top of each layer must be in (0, %s]", + MAX_TOP); E.checkArgument(capacity > 0, "The capacity of each layer must be > 0, " + "but got %s", capacity); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java index 889007c142..e85f995bcd 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/algorithm/SingleSourceShortestPathTraverser.java @@ -212,7 +212,7 @@ private double edgeWeight(HugeEdge edge) { !edge.property(this.weight).isPresent()) { edgeWeight = 1.0; } else { - edgeWeight = toDouble(edge.value(this.weight)); + edgeWeight = this.toDouble(edge.value(this.weight)); } return edgeWeight; }