Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit af61d7a

Browse files
knutwalkerjexp
authored andcommitted
Load correct weight property for Louvain
Add bigger ASP test that compares multiple SP impl Don't require weightProp for Louvain Fix SSP test
1 parent d954e18 commit af61d7a

File tree

4 files changed

+698
-103
lines changed

4 files changed

+698
-103
lines changed

algo/src/main/java/org/neo4j/graphalgo/LouvainProc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ private HeavyGraph load(ProcedureConfiguration config) {
131131
return (HeavyGraph) new GraphLoader(api, Pools.DEFAULT)
132132
.withOptionalLabel(config.getNodeLabelOrQuery())
133133
.withOptionalRelationshipType(config.getRelationshipOrQuery())
134-
.withRelationshipWeightsFromProperty(
135-
ProcedureConstants.PROPERTY_PARAM,
134+
.withOptionalRelationshipWeightsFromProperty(
135+
config.getProperty(),
136136
config.getPropertyDefaultValue(1.0))
137137
.withDirection(Direction.BOTH)
138138
.load(HeavyGraphFactory.class);

algo/src/main/java/org/neo4j/graphalgo/impl/ShortestPathDijkstra.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ public class ShortestPathDijkstra extends Algorithm<ShortestPathDijkstra> {
3838
private final int nodeCount;
3939
// overall cost of the path
4040
private double totalCost;
41-
// target node id
42-
private int goal;
4341
private ProgressLogger progressLogger;
4442

4543
public ShortestPathDijkstra(Graph graph) {
@@ -66,24 +64,21 @@ public ShortestPathDijkstra compute(long startNode, long goalNode) {
6664
}
6765

6866
public ShortestPathDijkstra compute(long startNode, long goalNode, Direction direction) {
69-
visited.clear();
70-
queue.clear();
67+
reset();
68+
7169
int node = graph.toMappedNodeId(startNode);
72-
goal = graph.toMappedNodeId(goalNode);
70+
int goal = graph.toMappedNodeId(goalNode);
7371
costs.put(node, 0.0);
7472
queue.add(node, 0.0);
7573
run(goal, direction);
76-
finalPath.clear();
77-
totalCost = NO_PATH_FOUND;
7874
if (!path.containsKey(goal)) {
7975
return this;
8076
}
77+
totalCost = costs.get(goal);
8178
int last = goal;
82-
totalCost = 0.0;
8379
while (last != PATH_END) {
8480
finalPath.addFirst(last);
8581
last = path.getOrDefault(last, PATH_END);
86-
totalCost += costs.get(last);
8782
}
8883
return this;
8984
}
@@ -166,6 +161,15 @@ public ShortestPathDijkstra release() {
166161
return this;
167162
}
168163

164+
private void reset() {
165+
visited.clear();
166+
queue.clear();
167+
costs.clear();
168+
path.clear();
169+
finalPath.clear();
170+
totalCost = NO_PATH_FOUND;
171+
}
172+
169173
/**
170174
* Result DTO
171175
*/

0 commit comments

Comments
 (0)