This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch olap-algo in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git
commit 199fb16ea3535bb03fc72989093ca3f1538c398d Author: Jermy Li <[email protected]> AuthorDate: Sun Aug 16 19:30:16 2020 +0800 fix DegreeCentrality degree count limit OOL (#39) Change-Id: I1b055130c75edce039a97822d9154e1214bc80c2 --- .../job/algorithm/cent/DegreeCentralityAlgorithm.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/DegreeCentralityAlgorithm.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/DegreeCentralityAlgorithm.java index b2030e845..54b72c2bf 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/DegreeCentralityAlgorithm.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/DegreeCentralityAlgorithm.java @@ -19,16 +19,18 @@ package com.baidu.hugegraph.job.algorithm.cent; +import java.util.Arrays; import java.util.Iterator; +import java.util.List; import java.util.Map; import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; -import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import com.baidu.hugegraph.backend.id.Id; import com.baidu.hugegraph.job.UserJob; import com.baidu.hugegraph.structure.HugeEdge; +import com.baidu.hugegraph.traversal.algorithm.EdgeStep; import com.baidu.hugegraph.type.define.Directions; public class DegreeCentralityAlgorithm extends AbstractCentAlgorithm { @@ -153,10 +155,10 @@ public class DegreeCentralityAlgorithm extends AbstractCentAlgorithm { } private long degree(Id source, String label) { - Id labelId = this.getEdgeLabelId(label); - Iterator<Edge> edges = this.edgesOfVertex(source, Directions.BOTH, - labelId, NO_LIMIT); - return IteratorUtils.count(edges); + List<String> labels = label == null ? null : Arrays.asList(label); + EdgeStep step = new EdgeStep(this.graph(), Directions.BOTH, + labels, null, NO_LIMIT, 0); + return this.edgesCount(source, step); } } }
