mardi 27 février 2018

Neo4j find repeating pattern starting from node

I' currently working with neo4j and try to construct a cypher query which suits my use case. I have a graph with the following structure

(NODE_A)-RELATION_A->(NODE_B)-RELATION_B->(NODE_A)-RELATION_A-> ... repeat ...

I know the first NODE_A and want each subsequent NODE_A and NODE_B which match the two Relations (RELATION_A and RELATION_B). If Í construct a cypher query it looks like this

MATCH (a:NODE_A)-[:RELATION_A]->(b:NODE_B)-[:RELATION_B]-(c:NODE_A) WHERE id(a)=1 RETURN [a,b,c] as result

But this only returns as result the pattern NODE_A-RELATION_A->NODE_B-RELATION_B->NODE_A

If I leave out the "WHERE id(a) = 1" it get the correct result, but then it returns all nodes that match the pattern.

How do I specify a start node from which the query to execute from?

Aucun commentaire:

Enregistrer un commentaire