Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-24-2022 03:05 PM
I want to calculate Shortestpath between nodes in Bloom - but I have some 'resource' nodes that are returned as the shortest path that I want to filter out.
Question
Find the shortest Path from (IndustryA) to (GoalA)
Source Graph contains:
(IndustryA)-[:requires]->(CapabilityA)<-[:improves]-(CapabilityB)-[:supports]->(GoalA)
(ResourceA)<-[:source]-(IndustryA)
(ResourceA)<-[:source]-(CapabilityA)
(ResourceA)<-[:source]-(GoalA)
Desired outcome is the first path above, but because ResourceA is linked to the other elements it is naturally the shortest path. I removed Resource nodes from the perspective, but they are still returned. If 'Hide uncategorized nodes' is selected then no path is returned.
I realize the cypher for this is more complicated than what the basic Shortestpath is designed to do, and my request is deeper than what Bloom may provide - but the behavior I would like is that the Bloom perspective could act as a filter for the Shortestpath algorithm if nodes are not included in the perspective?
01-26-2022 08:32 AM
I discovered - by reading more of the documentation - that the cypher commands for shortestPath and allShortestPaths that are used in MATCH .. WHERE statements can be filtered to ignore certain relationship types. I created a Search Phrase in Bloom to take advantage of this:
The below search phrase displays all of the paths from Industry to Goal, but ignores 'resource' type relationships.
MATCH (i:Industry {name: $industry} ),
(g:Goal {name: $goal}),
p = allShortestPaths((i)-[*1..6]-(g))
WHERE none(r IN relationships(p) WHERE type(r) = 'source' or type(r) = 'resource')
RETURN p
All the sessions of the conference are now available online