neo4j-contrib / neo4j-graph-algorithms

Efficient Graph Algorithms for Neo4j
https://github.com/neo4j/graph-data-science/
GNU General Public License v3.0
770 stars 195 forks source link

PageRank query returning different results from versions #800

Closed JMHReif closed 5 years ago

JMHReif commented 5 years ago

Writing pageRank to graph and getting different results from algorithms versions. Queries are below. Old version of algorithm is 3.4.0.0, new versions 3.4.7.0 and 3.5.1.0 are returning different pageRank calculations. Using GameOfThrones data set (guide: "play data_science"), Varys shows up on old version pageRank list, but not on the list with new versions.

Write pagerank value: CALL algo.pageRank("Character", "INTERACTS1", {direction: "BOTH", writeProperty:'book1PageRank'})

Query returning highest pagerank values: MATCH (c:Character) WITH c, [(c)-[r:INTERACTS1]-(other) | {character: other.name, weight: r.weight}] AS interactions RETURN c.name, c.book1PageRank, c.book1BetweennessCentrality, apoc.coll.sum([i in interactions | i.weight]) AS totalInteractions, [i in apoc.coll.reverse(apoc.coll.sortMaps(interactions, 'weight'))[..5] | i.character] as charactersInteractedWith ORDER BY c.book1PageRank DESC LIMIT 10

mneedham commented 5 years ago

We chatted about this separately and it's because PageRank didn't used to respect the direction parameter in earlier versions, but now it does.