Следующий алгоритм находит рейтинг страницы (обратите внимание, что это измененная версия алгоритма рейтинга страниц):
/* we have to go through all nodes */
MATCH (node:Page)
WITH
COLLECT(distinct node) AS pages
UNWIND pages as dest
/* let's find all source citations for a given node */
MATCH (source:Page)-[:NEXT]->(dest)
WITH
COLLECT(DISTINCT source) AS sources,
dest AS dest
UNWIND sources AS src
/* we have to know how many relationships the source node has */
MATCH (src)-[r:NEXT]->(dest)
WITH src, dest, sum(r.weight) AS prob
MATCH (src)-[r:NEXT]->()
WITH
/* The source citation will pass a portion of its pagerank as juice */
src.pagerank * (prob/ sum(r.weight)) AS juice,
dest AS dest
/* now we have all information to update the destination node with the new pagerank */
WITH
sum(juice) AS p,
dest AS dest
/* Using damping factor d = 0.85 */
set dest.pagerank = 0.15 + 0.85 * p;
Теперь для данного графика:
LOAD CSV WITH HEADERS FROM "file:\\graphUnioned1.csv" AS csvLine
MERGE (s:Node {value:csvLine.s})
MERGE (o:Node {value:csvLine.o})
MERGE (s)-[:REL {weight: toFloat(csvLine.p)}]->(o);
Как сделатьЯ нахожу рейтинг страницы всех узлов на графике.Я хочу запустить вышеупомянутый алгоритм PageRank итеративно до 100 итераций