I have created a property graph of a web site (where Cids are content ids or pages on the site). The movement of users around the site between Cids / pages is captured by the directed USER_MOVEMENT {weight: integer} relationship. It has a weight associated, the aggregated count of the number of people moving between those Cids in a given time period.
Using APOC
I start by filtering the Cid nodes for a given criteria, to do with their influence around the cite. I'm interested in the top 10
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn,
apoc.any.property('USER_MOVEMENT[>]', 'weight') AS usersOut
;
I've tried a few combinations of the last line of code to no avail. The guidance is a bit unclear apoc.any.property(node/rel/map)
i.e. apoc.any.property(u, 'USER_MOVEMENT>', 'weight') AS usersOut
To total the weights I would need to put into sum() function.
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) -[r:USER_MOVEMENT]-> ()WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn, sum(
r.weight) AS usersOut
;
#### Neo.ClientError.Statement.SyntaxError
Neo.ClientError.Statement.SyntaxError: Variable `r` not defined (line 6, column 1 (offset: 370)) "r.weight) AS usersOut" ^
Thanks @anthapu, I also thought of trying this approach, but it fails as r is not defined. Is it because we are not passing r in the WITH statement? How might we do that, I'm unsure.
I guess we need to rewrite the query like this. Apply match after we get the users of interest to get the relation.
// Only find content that have a pagerank score in the top X% of content
MATCH (u:Cid) WHERE u.pagerank > 7.775
// Find the top 10 of those users
WITH u ORDER BY u.pagerank DESC LIMIT 10
MATCH (u)-[r:USER_MOVEMENT]-> ()
RETURN u.name AS name, u.pagerank AS pageRank, apoc.node.degree.out(u, 'USER_MOVEMENT') AS pathsOut, apoc.node.degree.in(u, 'USER_MOVEMENT') AS pathsIn, sum(
r.weight) AS usersOut
;```