Skip to content

Commit 13ca96e

Browse files
Write array properties as an inner list with a single type
Co-Authored-By: Sören Reichardt <soren.reichardt@neotechnology.com>
1 parent 73fe13e commit 13ca96e

File tree

2 files changed

+56
-32
lines changed

2 files changed

+56
-32
lines changed

algo/src/main/java/org/neo4j/gds/louvain/Louvain.java

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.neo4j.gds.api.Graph;
2626
import org.neo4j.gds.api.IdMap;
2727
import org.neo4j.gds.api.RelationshipIterator;
28-
import org.neo4j.gds.api.properties.nodes.LongNodePropertyValues;
2928
import org.neo4j.gds.api.properties.nodes.NodePropertyValues;
3029
import org.neo4j.gds.beta.modularity.ImmutableModularityOptimizationStreamConfig;
3130
import org.neo4j.gds.beta.modularity.ModularityOptimization;
@@ -35,12 +34,11 @@
3534
import org.neo4j.gds.core.concurrency.ParallelUtil;
3635
import org.neo4j.gds.core.loading.construction.GraphFactory;
3736
import org.neo4j.gds.core.loading.construction.RelationshipsBuilder;
37+
import org.neo4j.gds.core.utils.OriginalIdNodePropertyValues;
3838
import org.neo4j.gds.core.utils.paged.HugeLongArray;
3939
import org.neo4j.gds.core.utils.partition.Partition;
4040
import org.neo4j.gds.core.utils.partition.PartitionUtils;
4141
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker;
42-
import org.neo4j.values.storable.Value;
43-
import org.neo4j.values.storable.Values;
4442

4543
import java.util.Optional;
4644
import java.util.OptionalLong;
@@ -98,7 +96,13 @@ public Louvain compute() {
9896
long maxCommunityId = buildDendrogram(workingGraph, ranLevels, modularityOptimization);
9997

10098
workingGraph = summarizeGraph(workingGraph, modularityOptimization, maxCommunityId);
101-
nextSeedingValues = new OriginalIdNodePropertyValues(workingGraph);
99+
nextSeedingValues = new OriginalIdNodePropertyValues(workingGraph) {
100+
@Override
101+
public OptionalLong getMaxLongPropertyValue() {
102+
// We want to use the maxSeedCommunity with value 0 in all subsequent iterations
103+
return OptionalLong.empty();
104+
}
105+
};
102106

103107
if (workingGraph.nodeCount() == oldNodeCount
104108
|| workingGraph.nodeCount() == 1
@@ -269,34 +273,6 @@ public void release() {
269273
this.rootGraph.releaseTopology();
270274
}
271275

272-
static class OriginalIdNodePropertyValues implements LongNodePropertyValues {
273-
private final Graph graph;
274-
275-
public OriginalIdNodePropertyValues(Graph graph) {
276-
this.graph = graph;
277-
}
278-
279-
@Override
280-
public long longValue(long nodeId) {
281-
return graph.toOriginalNodeId(nodeId);
282-
}
283-
284-
@Override
285-
public Value value(long nodeId) {
286-
return Values.longValue(longValue(nodeId));
287-
}
288-
289-
@Override
290-
public OptionalLong getMaxLongPropertyValue() {
291-
return OptionalLong.empty();
292-
}
293-
294-
@Override
295-
public long size() {
296-
return graph.nodeCount();
297-
}
298-
}
299-
300276
static final class RelationshipCreator implements Runnable {
301277

302278
private final RelationshipsBuilder relationshipsBuilder;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.gds.core.utils;
21+
22+
import org.neo4j.gds.api.IdMap;
23+
import org.neo4j.gds.api.properties.nodes.LongNodePropertyValues;
24+
25+
import java.util.OptionalLong;
26+
27+
public class OriginalIdNodePropertyValues implements LongNodePropertyValues {
28+
private final IdMap idMap;
29+
30+
public OriginalIdNodePropertyValues(IdMap idMap) {
31+
this.idMap = idMap;
32+
}
33+
34+
@Override
35+
public long longValue(long nodeId) {
36+
return idMap.toOriginalNodeId(nodeId);
37+
}
38+
39+
@Override
40+
public OptionalLong getMaxLongPropertyValue() {
41+
return OptionalLong.of(idMap.highestNeoId());
42+
}
43+
44+
@Override
45+
public long size() {
46+
return idMap.nodeCount();
47+
}
48+
}

0 commit comments

Comments
 (0)