Neo4j Page Rank Algorithm
Creating the Graph Database
Create(n:node{name:'A'}),(n1:node{name:'B'}),(n2:node{name:'C'}),(n3:node{name:'D'}),(n4:node{name:'E'})
match(n:node{name:'A'}),(n1:node{name:'B'}) create (n)-[d:distance]->(n1)
match(n:node{name:'A'}),(n1:node{name:'C'}) create (n)-[d:distance]->(n1)
match(n:node{name:'A'}),(n1:node{name:'D'}) create (n)-[d:distance]->(n1)
match(n:node{name:'B'}),(n1:node{name:'C'}) create (n)-[d:distance]->(n1)
match(n:node{name:'D'}),(n1:node{name:'C'}) create (n)-[d:distance]->(n1)
match(n:node{name:'D'}),(n1:node{name:'E'}) create (n)-[d:distance]->(n1)
match(n:node{name:'C'}),(n1:node{name:'E'}) create (n)-[d:distance]->(n1)
Iteration 1 Query
CALL algo.pageRank.stream('location', 'distance', {iterations:1, dampingFactor:0.85})
YIELD nodeId, score
RETURN algo.getNodeById(nodeId).name AS page, score
ORDER BY score DESC
Iteration 2 Query
CALL algo.pageRank.stream('location', 'distance', {iterations:2, dampingFactor:0.85})
YIELD nodeId, score
RETURN algo.getNodeById(nodeId).name AS page, score
ORDER BY score DESC