How do I return just the portion of a variable length pattern path that meets some criteria?
In the example below, the following cypher query will return both blue & red nodes.
MATCH p=(a:Person)-[:KNOWS*1..10]->(b:Person)-[:KNOWS]->(j:Person { name: 'Jane'})
RETURN p
However, I want to return the blue nodes that have an incoming relationship confidence_factor >= 0.75. The issue is that everything I've tried either
- Eliminates the entire upper mixed blue/red path b/c it's got one rel that fails test
- Eliminates just the Jim->Erin rel b/c it fails the test.
Effectively, I want all sequential nodes going backwards from Jane where relationship confidence_factor >= 0.75 but a given path should stop as soon as it encounters a rel that fails that test, and NOT CONTINUE, even if other relationships between nodes in that path might pass (e.g. Tom-[:KNOWS]->Jim)
CREATE (one:Person { name: 'Tom'})
,(two:Person { name: 'Jim'})
,(three:Person { name: 'Erin'})
,(four:Person { name: 'Kevin'})
,(five:Person { name: 'Skylar'})
,(six:Person { name: 'Jane'})
,(one)-[:KNOWS {confidence_factor:0.80}]->(two)
,(two)-[:KNOWS {confidence_factor:0.05}]->(three)
,(three)-[:KNOWS {confidence_factor:0.85}]->(six)
,(four)-[:KNOWS {confidence_factor:0.90}]->(five)
,(five)-[:KNOWS {confidence_factor:0.95}]->(six)
;