I want to select a subgraph(S) from my neo4j database and use another query on S to find if two given nodes are connected. Is there a way to write a query in neo4j ? I'm using node.js and Cypher. EDIT: I'm doing something similar to this, for example:
Match (u:User)-[:adds]->(y:Paper)-[:consistsOf]->(e:L2)-[]->(m:L3)
where u.username = 'test'
MATCH p=(m:L3)-[r:gives*1..4]->(n:L3)
...
Thanks
In your example, you could use the WITH clause to connect the 2 MATCH statements, like this (cleaned up a little):
MATCH (u:User {username:'test'})-[:adds]->(y:Paper)-[:consistsOf]->(e:L2)-->(m:L3)
WITH m
MATCH p=(m)-[r:gives*1..4]->(n:L3)
...
The WITH clause is like RETURN, except that its purpose is to pass value(s) from one query to the next. In this case, only 'm' is being passed, and so the second MATCH will not be aware of 'u', 'y', or 'e'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With