Find path between nodes through cypher

In Neo4j terms you want to find paths between P1 and P3. A relationship connects just two neighbors.

I assume P nodes carry a Person label, and have a name property, in which case you can use:

MATCH p=(p1:Person {name:'P1'})-[:SENT|:TO|:CC|:BCC*1..20]->(p3:Person {name:'P3'})
RETURN p

In a lot of cases you're interested in the shortest path between them:

MATCH p=shortestPath((p1:Person {name:'P1'})-[:SENT|:TO|:CC|:BCC*1..20]->(p3:Person {name:'P3'})
RETURN p

Answer to the updated question:

I assume your email nodes carry a label of Email and have a property mailId.

MATCH (mailToTrack:Email {mailId: 'mymailid'})-[:Reply_Of*1..100]->()-[:TO|:CC|:BCC]->(person)
RETURN distinct person

Tags:

Neo4J

Cypher