Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Expect disruption to service on Thursday, Feb. 9!

Using ShortestPath in Bloom but ignoring nodes not in perspective

Node Link

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.
Find the shortest Path from (IndustryA) to (GoalA)

Source Graph contains:

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?


Node Link

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')
Nodes 2022
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online