Skip to content

Commit 5025553

Browse files
Merge pull request #9735 from IoannisPanagiotas/more-bug-fixing-pcst
Correct edgeparts assignment whne generating new weights
2 parents 4ce0751 + 7d69de0 commit 5025553

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

algo/src/main/java/org/neo4j/gds/pricesteiner/GrowthPhase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ private void generateNewEdgeEvents(
213213
boolean vClusterActive
214214
) {
215215
if (vClusterActive) {
216-
edgeEventsQueue.addWithCheck(uCluster, vPart, moat + r / 2);
217-
edgeEventsQueue.addWithCheck(vCluster, uPart, moat + r / 2);
216+
edgeEventsQueue.addWithCheck(uCluster, uPart, moat + r / 2);
217+
edgeEventsQueue.addWithCheck(vCluster, vPart, moat + r / 2);
218218
} else {
219-
edgeEventsQueue.addWithCheck(uCluster, vPart, moat + r);
219+
edgeEventsQueue.addWithCheck(uCluster, uPart, moat + r);
220220
/*
221221
* remember that we do a increase operation when merging queues, so the `moat` will become equal to mergeTimeStamp
222222
* and processed next iteration
223223
*/
224-
edgeEventsQueue.addWithoutCheck(vCluster, uPart, moat);
224+
edgeEventsQueue.addWithoutCheck(vCluster, vPart, moat);
225225
}
226226
}
227227

algo/src/test/java/org/neo4j/gds/pricesteiner/GrowthPhaseTest.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,66 @@ void shouldExecuteGrowthPhaseCorrectlyWithUniqueWeights() {
229229
}
230230
}
231231

232+
@Nested
233+
@GdlExtension
234+
class DisconnectedAndParallelEdgesGraph{
235+
236+
@GdlGraph(orientation = Orientation.UNDIRECTED)
237+
private static final String DB_CYPHER =
238+
"CREATE " +
239+
"(a0:Node{prize: 4.0})," +
240+
"(a1:Node{prize: 9.0})," +
241+
"(a2:Node{prize: 8.0})," +
242+
"(a3:Node{prize: 0.0})," +
243+
"(a4:Node{prize: 7.0})," +
244+
"(a0)-[:R{w:7.0}]->(a3)," +
245+
"(a1)-[:R{w:3.0}]->(a3)," +
246+
"(a1)-[:R{w:2.0}]->(a3)," +
247+
"(a2)-[:R{w:4.0}]->(a4)," +
248+
"(a2)-[:R{w:4.0}]->(a4)";
249+
250+
@Inject
251+
private TestGraph graph;
252+
253+
@Test
254+
void shouldFindCorrectAnswer() {
255+
256+
var prizes = graph.nodeProperties("prize");
257+
258+
var growthPhase = new GrowthPhase(graph, prizes::doubleValue,ProgressTracker.NULL_TRACKER,TerminationFlag.RUNNING_TRUE);
259+
growthPhase.grow();
260+
261+
var clusterStructure = growthPhase.clusterStructure();
262+
263+
var a0 = graph.toMappedNodeId("a0");
264+
var a1 = graph.toMappedNodeId("a1");
265+
var a2 = graph.toMappedNodeId("a2");
266+
var a3 = graph.toMappedNodeId("a3");
267+
var a4 = graph.toMappedNodeId("a4");
268+
269+
assertThat(clusterStructure.inactiveSince(a3)).isEqualTo(0);
270+
271+
assertThat(clusterStructure.inactiveSince(a1)).isEqualTo(2);
272+
273+
assertThat(clusterStructure.inactiveSince(a2)).isEqualTo(2);
274+
assertThat(clusterStructure.inactiveSince(a4)).isEqualTo(2);
275+
276+
assertThat(clusterStructure.inactiveSince(a0)).isEqualTo(4);
277+
278+
assertThat(clusterStructure.inactiveSince(7)).isEqualTo(9);
279+
280+
var lastCluster = clusterStructure.singleActiveCluster();
281+
282+
var otherCluster = 5; //trick to find correct placement
283+
if (lastCluster ==5 ){
284+
otherCluster= 6;
285+
}
286+
assertThat(clusterStructure.inactiveSince(otherCluster)).isEqualTo(5);
287+
288+
289+
}
290+
291+
}
292+
232293

233294
}

0 commit comments

Comments
 (0)