-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dedicated PageRank variant configs
- Loading branch information
Showing
49 changed files
with
1,186 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankAlgorithmFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import com.carrotsearch.hppc.LongScatterSet; | ||
import org.neo4j.gds.GraphAlgorithmFactory; | ||
import org.neo4j.gds.api.Graph; | ||
import org.neo4j.gds.beta.pregel.Pregel; | ||
import org.neo4j.gds.core.concurrency.DefaultPool; | ||
import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; | ||
import org.neo4j.gds.core.utils.progress.tasks.Task; | ||
import org.neo4j.gds.mem.MemoryEstimation; | ||
import org.neo4j.gds.termination.TerminationFlag; | ||
|
||
import static org.neo4j.gds.pagerank.PageRankVariant.ARTICLE_RANK; | ||
|
||
public class ArticleRankAlgorithmFactory<C extends ArticleRankConfig> extends GraphAlgorithmFactory<PageRankAlgorithm<C>, C> { | ||
|
||
@Override | ||
public String taskName() { | ||
return ARTICLE_RANK.taskName(); | ||
} | ||
|
||
@Override | ||
public PageRankAlgorithm<C> build( | ||
Graph graph, | ||
C configuration, | ||
ProgressTracker progressTracker | ||
) { | ||
|
||
var degreeFunction = DegreeFunctions.pageRankDegreeFunction( | ||
graph, | ||
configuration.hasRelationshipWeightProperty(), configuration.concurrency() | ||
); | ||
|
||
var mappedSourceNodes = new LongScatterSet(configuration.sourceNodes().size()); | ||
configuration.sourceNodes().stream() | ||
.mapToLong(graph::toMappedNodeId) | ||
.forEach(mappedSourceNodes::add); | ||
|
||
double avgDegree = DegreeFunctions.averageDegree(graph, configuration.concurrency()); | ||
var computation = new ArticleRankComputation<>(configuration, mappedSourceNodes, degreeFunction, avgDegree); | ||
|
||
return new PageRankAlgorithm<>( | ||
graph, | ||
configuration, | ||
computation, | ||
ARTICLE_RANK, | ||
DefaultPool.INSTANCE, | ||
progressTracker, | ||
TerminationFlag.RUNNING_TRUE | ||
); | ||
} | ||
|
||
@Override | ||
public Task progressTask(Graph graph, C config) { | ||
return Pregel.progressTask(graph, config, taskName()); | ||
} | ||
|
||
@Override | ||
public MemoryEstimation memoryEstimation(C configuration) { | ||
return new PageRankMemoryEstimateDefinition().memoryEstimation(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import org.neo4j.gds.annotation.Configuration; | ||
|
||
@Configuration("ArticleRankConfigImpl") | ||
public interface ArticleRankConfig extends RankConfig | ||
{ | ||
@Configuration.DoubleRange(min = 0, max = 1, maxInclusive = false) | ||
default double dampingFactor() { | ||
return 0.85; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankMutateConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import org.neo4j.gds.annotation.Configuration; | ||
import org.neo4j.gds.config.MutateNodePropertyConfig; | ||
import org.neo4j.gds.core.CypherMapWrapper; | ||
|
||
@Configuration | ||
public interface ArticleRankMutateConfig extends ArticleRankConfig, MutateNodePropertyConfig { | ||
|
||
static ArticleRankMutateConfig of(CypherMapWrapper userInput) { | ||
return new ArticleRankMutateConfigImpl(userInput); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankStatsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import org.neo4j.gds.annotation.Configuration; | ||
import org.neo4j.gds.core.CypherMapWrapper; | ||
|
||
@Configuration | ||
public interface ArticleRankStatsConfig extends ArticleRankConfig { | ||
|
||
public static ArticleRankStatsConfig of(CypherMapWrapper userInput) { | ||
return new ArticleRankStatsConfigImpl(userInput); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankStreamConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import org.neo4j.gds.annotation.Configuration; | ||
import org.neo4j.gds.core.CypherMapWrapper; | ||
|
||
@Configuration | ||
public interface ArticleRankStreamConfig extends ArticleRankConfig { | ||
|
||
public static ArticleRankStreamConfig of(CypherMapWrapper userInput) { | ||
return new ArticleRankStreamConfigImpl(userInput); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
algo/src/main/java/org/neo4j/gds/pagerank/ArticleRankWriteConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Neo4j is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.gds.pagerank; | ||
|
||
import org.neo4j.gds.annotation.Configuration; | ||
import org.neo4j.gds.config.WritePropertyConfig; | ||
import org.neo4j.gds.core.CypherMapWrapper; | ||
|
||
@Configuration | ||
public interface ArticleRankWriteConfig extends ArticleRankConfig, WritePropertyConfig { | ||
|
||
public static ArticleRankWriteConfig of(CypherMapWrapper userInput) { | ||
return new ArticleRankWriteConfigImpl(userInput); | ||
} | ||
} |
Oops, something went wrong.