Skip to content

Commit

Permalink
improvement: sssp algorithm output filter
Browse files Browse the repository at this point in the history
  • Loading branch information
diaohancai committed Mar 13, 2024
1 parent e295b4d commit 724fbd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,8 @@ private boolean isAllTargetsReached(Vertex vertex) {
}
return false;
}

public IdSet getTargetIdSet() {
return targetIdSet;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.hugegraph.computer.core.config.Config;
import org.apache.hugegraph.computer.core.graph.vertex.Vertex;
import org.apache.hugegraph.computer.core.output.hg.HugeGraphOutput;
import org.apache.hugegraph.computer.core.worker.Computation;
import org.apache.hugegraph.util.JsonUtil;

public class SingleSourceShortestPathOutput extends HugeGraphOutput<String> {
Expand All @@ -45,4 +47,10 @@ protected String value(Vertex vertex) {
map.put("total_weight", value.totalWeight());
return JsonUtil.toJson(map);
}

@Override
public boolean filter(Config config, Computation computation, Vertex vertex) {
SingleSourceShortestPath sssp = (SingleSourceShortestPath) computation;
return sssp.getTargetIdSet() == null || sssp.getTargetIdSet().contains(vertex.id());
}
}

0 comments on commit 724fbd1

Please sign in to comment.