From d91e2a7faa5b03ee15476380de8f6f34caf5c189 Mon Sep 17 00:00:00 2001 From: Tomaz Bratanic Date: Thu, 19 Oct 2017 23:37:26 +0200 Subject: [PATCH] Fix pagerank yelp query --- doc/pagerank.adoc | 2 +- doc/scripts/pagerank.cypher | 14 +++++++++++++- doc/scripts/yelp-import.cypher | 13 ------------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/doc/pagerank.adoc b/doc/pagerank.adoc index c597dd169..f83dc3ac6 100644 --- a/doc/pagerank.adoc +++ b/doc/pagerank.adoc @@ -115,7 +115,7 @@ For now there is no option to load the the relationship as undirected, but we ca Undirected graph can be represented as https://en.wikipedia.org/wiki/Bidirected_graph[Bidirected graph], that is a directed graph in which the reverse of every relationship is also a relationship. We do not have to save this reversed relationship, we can project it using *cypher loading*. -We load all relationships and then use `UNION` to also load all relationships with reversed directions. +Note that relationship query does not specify direction of the relationship. This is applicable to all other algorithms, that use *cypher loading*. .Running algorithm on Yelp social network diff --git a/doc/scripts/pagerank.cypher b/doc/scripts/pagerank.cypher index 6e90468e4..57e23573f 100644 --- a/doc/scripts/pagerank.cypher +++ b/doc/scripts/pagerank.cypher @@ -44,4 +44,16 @@ CALL algo.pageRank( 'MATCH (p1:Page)-[:Link]->(p2:Page) RETURN id(p1) as source, id(p2) as target', {graph:'cypher', iterations:5, write: true}); -// end::cypher-loading[] \ No newline at end of file +// end::cypher-loading[] + +// tag::pagerank-stream-yelp-social[] + +call algo.pageRank.stream( +'MATCH (u:User) WHERE exists( (u)-[:FRIENDS]-() ) RETURN id(u) as id', +'MATCH (u1:User)-[:FRIENDS]-(u2:User) RETURN id(u1) as source, id(u2) as target', +{graph:'cypher'} +) yield node,score with node,score order by score desc limit 10 +return node {.name, .review_count, .average_stars,.useful,.yelping_since,.funny},score; + +// end::pagerank-stream-yelp-social[] + diff --git a/doc/scripts/yelp-import.cypher b/doc/scripts/yelp-import.cypher index be739512c..32500558a 100644 --- a/doc/scripts/yelp-import.cypher +++ b/doc/scripts/yelp-import.cypher @@ -103,16 +103,3 @@ ON CREATE SET cr.weight = weight ',{batchSize: 1}); // end::coocurence-graph[] - -// tag:pagerank-stream-yelp-social[] - -call algo.pageRank.stream( -'MATCH (u:User) WHERE exists( (u)-[:FRIENDS]-() ) RETURN id(u) as id', -'MATCH (u1:User)-[:FRIENDS]->(u2:User) RETURN id(u1) as source, id(u2) as target - UNION - MATCH (u1:User)-[:FRIENDS]->(u2:User) RETURN id(u2) as source, id(u1) as target', -{graph:'cypher'} -) yield node,score with node,score order by score desc limit 10 -return node {.name, .review_count, .average_stars,.useful,.yelping_since,.funny},score; - -// end:pagerank-stream-yelp-social[] \ No newline at end of file