O'Reilly logo

Learning Neo4j 3.x - Second Edition by Rik Van Bruggen, Jérôme Baton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

PageRank

PageRank is the algorithm that made Google stand out from the competition of search engines by ranking websites. It counts both the number and quality of a relation and deduces an importance for this node.

The rules are:

  • The more relations, the more important the node
  • The more relations with important nodes, the more important the node

First, let's create a thousand nodes:

FOREACH (id IN range(0,1000) | CREATE (n:Node {id:id}))

And, at most, a million relations:

MATCH (n1:Node),(n2:Node) WITH n1,n2 LIMIT 1000000 WHERE rand() < 0.1CREATE (n1)-[:TYPE_1]->(n2)

Then, let's call the pageRank algorithm:

MATCH (node:Node) WITH collect(node) AS nodes CALL apoc.algo.pageRank(nodes) YIELD node, score RETURN node, score ORDER BY score DESC ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required