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 c22d2d38dd1467912213e95f5cf0b57860ab50bb Author: houzhizhen <[email protected]> AuthorDate: Mon Sep 21 14:03:22 2020 +0800 update Betweenness with Stressness (#60) --- .../hugegraph/job/algorithm/AlgorithmPool.java | 4 +- .../job/algorithm/SubgraphStatAlgorithm.java | 6 +-- .../job/algorithm/cent/AbstractCentAlgorithm.java | 1 + ...gorithm.java => StressCentralityAlgorithm.java} | 44 +++++++++++----------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/AlgorithmPool.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/AlgorithmPool.java index 9a8412077..325293669 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/AlgorithmPool.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/AlgorithmPool.java @@ -22,7 +22,7 @@ package com.baidu.hugegraph.job.algorithm; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import com.baidu.hugegraph.job.algorithm.cent.BetweenessCentralityAlgorithm; +import com.baidu.hugegraph.job.algorithm.cent.StressCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.ClosenessCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.DegreeCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.EigenvectorCentralityAlgorithm; @@ -45,7 +45,7 @@ public class AlgorithmPool { INSTANCE.register(new CountEdgeAlgorithm()); INSTANCE.register(new DegreeCentralityAlgorithm()); - INSTANCE.register(new BetweenessCentralityAlgorithm()); + INSTANCE.register(new StressCentralityAlgorithm()); INSTANCE.register(new ClosenessCentralityAlgorithm()); INSTANCE.register(new EigenvectorCentralityAlgorithm()); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/SubgraphStatAlgorithm.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/SubgraphStatAlgorithm.java index bf3509734..09f994d14 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/SubgraphStatAlgorithm.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/SubgraphStatAlgorithm.java @@ -33,7 +33,7 @@ import com.baidu.hugegraph.backend.id.Id; import com.baidu.hugegraph.config.CoreOptions; import com.baidu.hugegraph.config.HugeConfig; import com.baidu.hugegraph.job.UserJob; -import com.baidu.hugegraph.job.algorithm.cent.BetweenessCentralityAlgorithm; +import com.baidu.hugegraph.job.algorithm.cent.StressCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.ClosenessCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.DegreeCentralityAlgorithm; import com.baidu.hugegraph.job.algorithm.cent.EigenvectorCentralityAlgorithm; @@ -158,8 +158,8 @@ public class SubgraphStatAlgorithm extends AbstractAlgorithm { Map<String, Object> parameters = ImmutableMap.copyOf(PARAMS); results.put("degrees", algo.call(job, parameters)); - algo = new BetweenessCentralityAlgorithm(); - results.put("betweeness", algo.call(job, parameters)); + algo = new StressCentralityAlgorithm(); + results.put("stress", algo.call(job, parameters)); algo = new EigenvectorCentralityAlgorithm(); results.put("eigenvectors", algo.call(job, parameters)); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/AbstractCentAlgorithm.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/AbstractCentAlgorithm.java index fd8453fff..752dc74ba 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/AbstractCentAlgorithm.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/AbstractCentAlgorithm.java @@ -157,6 +157,7 @@ public abstract class AbstractCentAlgorithm extends AbstractAlgorithm { // ignore non shortest path return false; } + // TODO: len may be smaller than shortest if (shortest == null) { triples.put(key, len); } else { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/BetweenessCentralityAlgorithm.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/StressCentralityAlgorithm.java similarity index 68% rename from hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/BetweenessCentralityAlgorithm.java rename to hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/StressCentralityAlgorithm.java index 968f636ba..87f1471d4 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/BetweenessCentralityAlgorithm.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/job/algorithm/cent/StressCentralityAlgorithm.java @@ -30,13 +30,13 @@ import com.baidu.hugegraph.job.UserJob; import com.baidu.hugegraph.type.define.Directions; import com.baidu.hugegraph.util.ParameterUtil; -public class BetweenessCentralityAlgorithm extends AbstractCentAlgorithm { +public class StressCentralityAlgorithm extends AbstractCentAlgorithm { public static final String KEY_WITH_BOUNDARY = "with_boundary"; @Override public String name() { - return "betweeness_centrality"; + return "stress_centrality"; } @Override @@ -48,16 +48,16 @@ public class BetweenessCentralityAlgorithm extends AbstractCentAlgorithm { @Override public Object call(UserJob<Object> job, Map<String, Object> parameters) { try (Traverser traverser = new Traverser(job)) { - return traverser.betweenessCentrality(direction(parameters), - edgeLabel(parameters), - depth(parameters), - degree(parameters), - sample(parameters), - withBoundary(parameters), - sourceLabel(parameters), - sourceSample(parameters), - sourceCLabel(parameters), - top(parameters)); + return traverser.stressCentrality(direction(parameters), + edgeLabel(parameters), + depth(parameters), + degree(parameters), + sample(parameters), + withBoundary(parameters), + sourceLabel(parameters), + sourceSample(parameters), + sourceCLabel(parameters), + top(parameters)); } } @@ -74,16 +74,16 @@ public class BetweenessCentralityAlgorithm extends AbstractCentAlgorithm { super(job); } - public Object betweenessCentrality(Directions direction, - String label, - int depth, - long degree, - long sample, - boolean withBoundary, - String sourceLabel, - long sourceSample, - String sourceCLabel, - long topN) { + public Object stressCentrality(Directions direction, + String label, + int depth, + long degree, + long sample, + boolean withBoundary, + String sourceLabel, + long sourceSample, + String sourceCLabel, + long topN) { assert depth > 0; assert degree > 0L || degree == NO_LIMIT; assert topN >= 0L || topN == NO_LIMIT;
