Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-24-2020 11:05 AM
Dear all,
I look for the cypher code enable to return only one path.
I assume that I have, A->B1->C1->D1->B1 and A->B2->C2->D2->B2.
I would to retrieve the components of these 2 cycles.
I try the following code but I retrieve 6 cycles
MATCH path=(l:LEU)-[:REL*2..]->(l)
WHERE all(r in relationships(path))
RETURN relationships(path) as rel
I get
path1 : B1->C1->D1
path2 : C1->D1->B1
path3 : D1->B1->C1
path4 : B2->C2->D2
path5 : C2->D2->B2
path6 : D2->B2->C2
How can I update the code to retrieve only path1 and path4 following an order based on id of node ?
Regards,
Alexandre
09-24-2020 01:03 PM
Try this:
MATCH (c:B1)
CALL apoc.path.subgraphAll(c, {maxLevel: 2})
YIELD nodes, relationships
RETURN nodes, relationships
MATCH (c:B2)
CALL apoc.path.subgraphAll(c, {maxLevel: 2})
YIELD nodes, relationships
RETURN nodes, relationships
All the sessions of the conference are now available online