New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inexact relationship parameter in apoc.algo.closeness()&apoc.algo.betweenness() #847

thenoNOno opened this Issue Jul 9, 2018 · 2 comments


None yet
2 participants

thenoNOno commented Jul 9, 2018

When the parameter of the incoming relation type is taken, all relations of the types in the graph are taken out for calculation.
In fact, when calculating closeness, it is more desirable to calculate only the relationship in the subgraph.
When I calculate on the subgraph

  1. It takes a lot of unnecessary computing resources.
  2. It has an indeterminate effect on the result of calculation (I don't know whether the same name relation in graph will participate in calculation).



public Stream closeness(
@name("types") List types,
@name("nodes") List nodes,
@name("direction") String direction) {
assertParametersNotNull(types, nodes);
try {
RelationshipType[] relationshipTypes = types.isEmpty()
? Util.allRelationshipTypes(db)
: Util.toRelTypes(types);
SingleSourceShortestPath sssp = new SingleSourceShortestPathDijkstra<>(
(relationship, dir) -> 1.0,
new DoubleAdder(),
new DoubleComparator(),


public static RelationshipType[] toRelTypes(List relTypeStrings) {
RelationshipType[] relTypes = new RelationshipType[relTypeStrings.size()];
for (int i = 0; i < relTypes.length; i++) {
relTypes[i] = RelationshipType.withName(relTypeStrings.get(i));
return relTypes;


This comment has been minimized.

Show comment
Hide comment

jexp Jul 9, 2018


Please use instead


jexp commented Jul 9, 2018

Please use instead


This comment has been minimized.

Show comment
Hide comment

thenoNOno commented Jul 9, 2018


@thenoNOno thenoNOno closed this Jul 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment