-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
165 additions
and
9 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
58 changes: 58 additions & 0 deletions
58
.../main/java/org/neo4j/gds/algorithms/centrality/specificfields/PageRankSpecificFields.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,58 @@ | ||
/* | ||
* 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.algorithms.centrality.specificfields; | ||
|
||
import java.util.Map; | ||
|
||
public class PageRankSpecificFields implements CentralityStatisticsSpecificFields { | ||
|
||
public static final PageRankSpecificFields EMPTY = new PageRankSpecificFields( | ||
0, | ||
false, | ||
Map.of() | ||
); | ||
|
||
private final long ranIterations; | ||
private final boolean didConverge; | ||
private final Map<String, Object> centralityDistribution; | ||
|
||
public PageRankSpecificFields( | ||
long ranIterations, | ||
boolean didConverge, | ||
Map<String, Object> centralityDistribution | ||
) { | ||
this.ranIterations = ranIterations; | ||
this.didConverge = didConverge; | ||
this.centralityDistribution = centralityDistribution; | ||
} | ||
|
||
public long ranIterations() { | ||
return ranIterations; | ||
} | ||
|
||
public boolean didConverge() { | ||
return didConverge; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> centralityDistribution() { | ||
return centralityDistribution; | ||
} | ||
} |
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
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
45 changes: 45 additions & 0 deletions
45
.../org/neo4j/gds/procedures/centrality/pagerank/PageRankComputationalResultTransformer.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,45 @@ | ||
/* | ||
* 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.procedures.centrality.pagerank; | ||
|
||
import org.neo4j.gds.algorithms.StatsResult; | ||
import org.neo4j.gds.algorithms.centrality.specificfields.PageRankSpecificFields; | ||
import org.neo4j.gds.pagerank.PageRankStatsConfig; | ||
|
||
public final class PageRankComputationalResultTransformer { | ||
|
||
private PageRankComputationalResultTransformer() {} | ||
|
||
public static PageRankStatsResult toStatsResult( | ||
StatsResult<PageRankSpecificFields> computationResult, | ||
PageRankStatsConfig configuration | ||
) { | ||
return new PageRankStatsResult( | ||
computationResult.algorithmSpecificFields().ranIterations(), | ||
computationResult.algorithmSpecificFields().didConverge(), | ||
computationResult.algorithmSpecificFields().centralityDistribution(), | ||
computationResult.preProcessingMillis(), | ||
computationResult.computeMillis(), | ||
computationResult.postProcessingMillis(), | ||
configuration.toMap() | ||
); | ||
} | ||
|
||
} |