Skip to content

Commit 9931c60

Browse files
minor
1 parent b7099cc commit 9931c60

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

algo/src/main/java/org/neo4j/gds/pagerank/InitialProbabilityFactory.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,33 @@
2626
import java.util.HashMap;
2727
import java.util.function.LongUnaryOperator;
2828

29-
public class InitialProbabilityFactory {
29+
public final class InitialProbabilityFactory {
3030

31-
public static InitialProbabilityProvider create(LongUnaryOperator toMappedId, double alpha, SourceNodes sourceNodes) {
32-
if (sourceNodes == SourceNodes.EMPTY_SOURCE_NODES){
31+
private InitialProbabilityFactory() {}
32+
33+
public static InitialProbabilityProvider create(
34+
LongUnaryOperator toMappedId,
35+
double alpha,
36+
SourceNodes sourceNodes
37+
) {
38+
if (sourceNodes == SourceNodes.EMPTY_SOURCE_NODES) {
3339
return new GlobalRestartProbability(alpha);
34-
}
35-
else if (sourceNodes instanceof ListSourceNodes){
40+
} else if (sourceNodes instanceof ListSourceNodes) {
3641
var newSourceNodes = sourceNodes.sourceNodes()
3742
.stream()
3843
.mapToLong(toMappedId::applyAsLong)
3944
.boxed()
4045
.toList();
4146
return new SourceBasedRestartProbabilityList(alpha, newSourceNodes);
42-
}
43-
else if (sourceNodes instanceof MapSourceNodes){
47+
} else if (sourceNodes instanceof MapSourceNodes) {
4448
var newMap = new HashMap<Long, Double>();
45-
for(var entry : ((MapSourceNodes) sourceNodes).map().entrySet()){
49+
for (var entry : ((MapSourceNodes) sourceNodes).map().entrySet()) {
4650
var newKey = toMappedId.applyAsLong(entry.getKey());
4751
newMap.put(newKey, entry.getValue());
4852
}
4953
return new SourceBasedRestartProbability(alpha, newMap);
50-
}
51-
else {
52-
throw new IllegalArgumentException("Unsupported source nodes: ");
54+
} else {
55+
throw new IllegalArgumentException("Unsupported source nodes type");
5356
}
5457
}
5558
}

0 commit comments

Comments
 (0)