cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Using ShortestPath in Bloom but ignoring nodes not in perspective

mike_hatch
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.
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?

1 REPLY 1

mike_hatch
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')
RETURN p
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit - November 16 - 17, 2022.


Free NODES Training Series


October 19th -

Intro to Neo4j


October 20th -

Healthcare Analytics Using Neo4j


October 25th -

Handling Neo4j data with Apache Hop


October 26th -

Blazing Fast Graphs: Hands-on with Apache Arrow and Neo4j


November 2nd -

Graph EDA Using the Neo4j GDS Client