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

Closed
thenoNOno opened this Issue Jul 9, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@thenoNOno

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.
because:
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).

path&code

~/neo4j-apoc-procedures/src/main/java/apoc/algo/Centrality.java

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<>(
0.0,
null,
(relationship, dir) -> 1.0,
new DoubleAdder(),
new DoubleComparator(),
Util.parseDirection(direction),
relationshipTypes);

~/neo4j-apoc-procedures/src/main/java/apoc/util/Util.java

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;
}

@jexp

This comment has been minimized.

Show comment
Hide comment
@jexp

jexp Jul 9, 2018

Member

Please use github.com/neo4j-contrib/neo4j-graph-algorithms instead

Member

jexp commented Jul 9, 2018

Please use github.com/neo4j-contrib/neo4j-graph-algorithms instead

@thenoNOno

This comment has been minimized.

Show comment
Hide comment
@thenoNOno

thenoNOno commented Jul 9, 2018

Thanks

@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