cancel
Showing results for 
Search instead for 
Did you mean: 

Using Virtual Relationships in ShortestPath algorithms

davidmakovoz
Node Clone

I am using Yen’s K-Shortest Paths algorithm. I have a situation when I have multiple 'redundant' paths, which I'd like to reduce to only one. Supplier (node) FILLS (relationship) multiple PurchaseOrders (node) and PurchaseOrders USED (relationship) by an Organization (node). There could be dozens or even hundreds of PurchaseOrders between a specific Supplier and a specific Organization, but for my purpose it's only path. It seems like the natural thing to use here is Virtual Relationships, which I have used for other types of queries.

However, the ShortestPath algorithms do not recognize Virtual Relationships, here is the error message I'm getting (PURCHASES_FROM is the name of the Virtual Relationship I created)

Failed to invoke procedure `gds.alpha.kShortestPaths.stream`: Caused by: java.lang.IllegalArgumentException: Invalid relationship projection, one or more relationship types not found: 'PURCHASES_FROM|...'

Is there a way I can get around this problem?

Thank you.

3 REPLIES 3

mark_needham
Neo4j
Neo4j

I don't think the library supports virtual relationships, but you should be able to achieve the same thing using a Cypher projection. See https://neo4j.com/docs/graph-data-science/current/management-ops/cypher-projection/

if you share the way that you create the virtual relationships, I can translate that into the appropriate Cypher projection code.

cypher projection doesn't return the result that can be used for visualization. Though I don't know if the author has already figured out the way to solve it, I am wondering what I can do to find the shortest path over virtual relationships or virtual graph.

Can you provide an example for- how to use projections for ShortestPath algorithms using virtual relationships?

Thanks

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.