Reputation: 1
In Neo4j, I am using a community detection algorithm and returning only the nodes and relationships belonging to the community assigned with the id '10', as seen below.
MATCH p=(a:Function)-[:BASED_ON]->(b:Requirement)-[:RESULT_OF]->(c:Scenario)
WHERE a.community = 10 AND b.community = 10 AND c.community = 10
RETURN p
I now want to further filter this subset of the graph database and display nodes and relationships belonging to community '10' that have a PageRank, determined using the PageRank centrality algorithm, that is greater than a specified value, for example 1.
I have attempted to do so using the following:
MATCH p=(a:Function)-[:BASED_ON]->(b:Requirement)-[:RESULT_OF]->(c:Scenario)
WHERE a.community = 10 AND b.community = 10 AND c.community = 10 AND c.pagerank >1
RETURN p
However this doesnt return the required result. Nodes of type 'Function' and 'Requirement' that themselves have pagerank greater than 1 are excluded if they are related to a 'Scenario' node with pagerank less than 1, as these nodes do not satisfy the MATCH clause.
What query could I use to ONLY display nodes belonging to community '10' that have pagerank greater than 1, independent of the pagerank of nodes they are connected to. In other words I want to return nodes with pagerank greater than 1 even if they are connected to another node, such as a 'Scenario' with pagerank less than 1, as seen in the previous code sample.
Any assistance would be greatly appreciated.
Upvotes: 0
Views: 243
Reputation: 1022
without knowing much more i'd suggest that you create a node Community
with id and link them to Function , Requirement and Scenario. and start there. the traversal will be much quicker.
match (:Community{Id:10})-[]-(x)
where (x:Function or x:Req or req:Sec) and x.pagerank >...
Upvotes: 1
Reputation: 4901
Wouldn't you achieve what you want with an OR clause ?
MATCH p=(a:Function)-[:BASED_ON]->(b:Requirement)-[:RESULT_OF]->(c:Scenario)
WHERE a.community = 10 AND b.community = 10 AND c.community = 10 AND (a.pagerank >1 OR b.pagerank >1 OR c.pagerank >1)
RETURN p
Achieving then to return results that have a pagerank > 1 on one of the nodes ?
Upvotes: 0