Search in sources :

Example 1 with PageRankArrayStorageParallelSPI

use of apoc.algo.pagerank.PageRankArrayStorageParallelSPI in project neo4j-apoc-procedures by neo4j-contrib.

the class PageRank method innerPageRank.

private Stream<NodeScore> innerPageRank(Long iterations, List<Node> nodes, RelationshipType... types) {
    try {
        PageRankArrayStorageParallelSPI pageRank = new PageRankArrayStorageParallelSPI(db, guard, pool);
        pageRank.compute(iterations.intValue(), types);
        return nodes.stream().map(node -> new NodeScore(node, pageRank.getResult(node.getId())));
    } catch (Exception e) {
        String errMsg = "Error encountered while calculating page rank";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
}
Also used : NodeScore(apoc.result.NodeScore) PageRankArrayStorageParallelSPI(apoc.algo.pagerank.PageRankArrayStorageParallelSPI)

Example 2 with PageRankArrayStorageParallelSPI

use of apoc.algo.pagerank.PageRankArrayStorageParallelSPI in project neo4j-apoc-procedures by neo4j-contrib.

the class PageRank method innerPageRankStats.

private Stream<PageRankStatistics> innerPageRankStats(int iterations, Map<String, Object> config, RelationshipType... types) {
    try {
        PageRankArrayStorageParallelSPI pageRank = new PageRankArrayStorageParallelSPI(db, guard, pool);
        pageRank.compute(iterations, types);
        if ((boolean) config.getOrDefault(SETTING_WRITE, DEFAULT_PAGE_RANK_WRITE)) {
            pageRank.writeResultsToDB();
        }
        return Stream.of(pageRank.getStatistics());
    } catch (Exception e) {
        String errMsg = "Error encountered while calculating page rank";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
}
Also used : PageRankArrayStorageParallelSPI(apoc.algo.pagerank.PageRankArrayStorageParallelSPI)

Aggregations

PageRankArrayStorageParallelSPI (apoc.algo.pagerank.PageRankArrayStorageParallelSPI)2 NodeScore (apoc.result.NodeScore)1